Domanda

I have a question about the parameter values in Reporting Services. I have two parameters:

@OrdersMonth
@OrdersPrevMonth

And each one has for values:

[Orders].[Month].[January 2014]

and so on for each month. For the second parameter I have the same values but different dimension:

[Orders].[PrevMonth].[January 2014]

and so on for each month.

The thing is that my parameter @OrdersMonth must be visible and parameter @OrdersPrevMonth must be hidden, but when the user select the value for @OrdersMonth, the last value (January 2014) must be updated too, but of course with its dimension.

[Orders].[Month].[January 2014]       -> visible
[Orders].[PrevMonth].[January 2014]   -> hidden

Any ideas would be much appreciated. Thanks

È stato utile?

Soluzione

You will need to make @OrdersPrevMonth a query based parameter that is dependent on @OrdersMonth. When you change @OrdersMonth the value for @OrdersPrevMonth is re-fetched.

To do this you will need to set @OrdersPrevMonth's options to "get data from query". In the SP or query you need to reference @OrdersMonth as a parameter.

To test this you can create another dataset and set the query or stored procedure simiuliar to:

CREATE PROCEDURE GetOrdersPrevMonthParameters
(
    @OrdersMonth NVARCHAR(75) 
)
AS

DECLARE @Result NVARCHAR(75)
SET @Result=
    CASE 
        WHEN @OrdersMonth='[Orders].[Month].[January 2014]' THEN '[Orders].[PrevMonth].[January 2014]'
        WHEN @OrdersMonth='[Orders].[Month].[March 2014]' THEN '[Orders].[PrevMonth].[March 2014]'
        ELSE
            NULL
    END
SELECT @Result

Note: You may want to formulate a programtic solution using a DATETIME field rather than a long verbose CASE statement for this, however for simplicity of the example I am using case.

Next, make your @OrderInPrevMonth parameter dependant on the GetOrdersPrevMonthParameters dataset. SSRS will automaitcly flag this parameter as a casecade to @OrdersMonth because it is a required parameter to the query for @OrdersPrevMonth.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top