Simon
Simon

Reputation: 103

SSRS: Two cascading date parameters do not refresh

I have an SSRS 2014 report with three parameters: @Period (text), @FromDate (date), and @ToDate (date). They work together by first selecting a value from the Period dropdown list (January, February, March etc...). Depending on what you period you choose, the @FromDate and @ToDate parameters change accordingly to reflect your choice. This works well, but the problem arises when you select a new period after having already selected one, as the date parameters do not refresh.

I have been looking at some suggestions and workarounds, but I have yet to find one that deals with two dependent date parameters. Any suggestions?

Upvotes: 0

Views: 3730

Answers (3)

Timothy Griffiths
Timothy Griffiths

Reputation: 1

This is working as intended, Microsoft doesn't want cascading date parameters to refresh if you change the parameter they are dependent on. However it's possible to get around it.

It requires two datasets for the two data parameters which return one row with the required data dependent on the @Period parameter e.g.

DECLARE @Dates as TABLE ([Period] INT, [Date] SMALLDATETIME) 

INSERT INTO @Dates VALUES
(1,DATEADD(s, 86340, DATEADD(dd,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))) ) 
,(2,DATEADD(DAY , 7-DATEPART(WEEKDAY,GETDATE()),DATEADD(MINUTE,- 1,DATEADD(DAY,0,DATEADD(day,DATEDIFF(day,0,GETDATE())+1,0)))) )
,(3,DATEADD(MINUTE,- 1,DATEADD(DAY,0,DATEADD(day,DATEDIFF(day,0,GETDATE()),0)))) 

SELECT 
    [Period]
    ,[Date]
FROM
    @Dates
WHERE 
    [Period] = @Period

Set the available values of the @Period parameter too match and set the default value of the data parameters to their matching datasets.

Now when you change the @Period parameter it forces the date datasets to be be rerun and your date parameters will default to the new result.

Upvotes: 0

Chris Tian
Chris Tian

Reputation: 240

As already stated, parameters which have no available values/default values from a cascading query won't refresh their default values.

Workaround: Create a one row dataset which calculates your DateFrom and DateTo dates, each in a separate column and depending on your @Period parameter, and assign the dataset to the available and default values of both your parameters. Disadvantage: you won't be able to edit the values when running the report, since the fields are populated by a dataset.

Upvotes: 0

Unbound
Unbound

Reputation: 197

The Date parameters once generated cannot be changed. It does not have the cascading facility and according to Microsoft, it's by design (it's how they wanted it to behave):

Follow this link please

Upvotes: 0

Related Questions