I have a requirement to implement a toggle in an SSRS report where the user of the report can select to filter on either dates 1) Termination Date, 2) Activation Date or 3) Billing Date
I've created the parameter in SSRS as @toggle with the values of T, A, B @Date_From is the field below that we want to start the date range filter @Date_To is the field below that we want to end the date range filter
In my TSQL query I have added this in the where clause:
AND ((@Toggle = 'A' AND BS.ActivatedDatePK BETWEEN (@Date_From) AND (@Date_To)) OR (@Toggle = 'T' AND BS.TerminationDatePK BETWEEN (@Date_From) AND (@Date_To)) OR (@Toggle = 'B' AND BS.BillingStartDatePK BETWEEN (@Date_From) AND (@Date_To)))
And I'm not getting any results for either of the parameters. Visual Studio isn't throwing any errors so somewhere my logic is just plan bad.
Does anyone have any ideas?
There are a few things to try here...
The logic actually looks OK to me (although being old an tired I might have missed something!)
All that said and done, it 'might' be easier to write your dataset query as an expression.
So, hit the function button next to the query text field in the dataset editor and then set it to an expression something like
="SELECT * FROM myTable WHERE BS." &
SWITCH(
Parameters!Toggle.Value = "A", "ActivatedDatePK",
Parameters!Toggle.Value = "T", "TerminationDatePK",
Parameters!Toggle.Value = "B", "BillingStartDatePK") &
" BETWEEN " & Parameters!Date_From.Value " AND " & Parameters!Date_To.Value
you might need to convert the dates to the correctly formatted strings...