Rich Uchytil
Rich Uchytil

Reputation: 509

Setting the default date value in SSRS to be filled in or blank based on another parameter

I've got parameters ScheduleMode, FromDate and ToDate. ScheduleMode can be Monthly, Weekly, or Manual. If it's Monthly or Weekly the FromDate and ToDate are set accordingly and that part I've got. If it's Manual I don't want a default value for FromDate and ToDate, I want them to be blank.

Any ideas? Thanks!

Upvotes: 1

Views: 61

Answers (1)

Hannover Fist
Hannover Fist

Reputation: 10860

I would use a SWITCH statement for your Date parameters. A SWITCH is like a CASE statement in other languages but using a comma for the THEN and ELSE keywords.

=SWITCH(Parameters!ScheduleMode.Value = "Weekly", TODAY.AddDays(1 - TODAY.DayOfWeek), 
        Parameters!ScheduleMode.Value = "Monthly", TODAY.AddDays(1 - TODAY.Day), 
        True, NOTHING)

The last line acts like an ELSE statement - if it doesn;t meet the first 2 criteria, it will always get the third.

NOTHING is equivalent to NULL in SSRS.

Upvotes: 1

Related Questions