Jorgen V
Jorgen V

Reputation: 313

Can a parameter in ssrs jump back to null?

So I'm making a report in SSRS 2012 3.0 where different timespans can be chosen. Default my 'Custom StartTime' and 'Custom EndTime' parameter is NULL. When the user selects the parameter 'Custom Timespan' in the Timespan Parameter he has the possibility to turn off the nulls and choose a custom date.

When he now wants to change the Timespan to 'This Year' the 'Custom StartTime' and 'Custom EndTime' will still be filled with the dates that he chose previously. Is there a way that these parameters can jump back to 'NULL' from the moment he chooses something else than 'Custom Timespan'?

'This Year' will fill up 2 other parameters (StartTime and EndTime) that are hidden but I don't think this makes any difference in my case.

This is the query I use in my report to manage the timespans

IF @CustomStartTime IS NOT NULL AND @CustomEndTime IS NOT NULL
       AND @CustomStartTime < @CustomEndTime
    BEGIN
        SELECT @StartTime = @CustomStartTime
        SELECT @EndTime = @CustomEndTime
    END

Upvotes: 0

Views: 29

Answers (1)

Mike D.
Mike D.

Reputation: 4104

Rather than having the if statement check if the custom times have been set to figure out when to use them it should check if "Custom Timespan" option has been selected and then use them, otherwise use the predetermined dates. This won't change the fact that user can see the custom times they've selected but they will be ignored when running the report.

So more like:

IF @TimePeriodSelect = "Custom Timespan" THEN
BEGIN
    @StartTime = @CustomStartTime
    @EndTime = @CustomEndTime
END

Upvotes: 1

Related Questions