user3691608
user3691608

Reputation: 47

SSRS report filtering based on a parameter

I have an SSRS report with a field called SetGroup. Each row has a SetGroup value of either 'Group 1' or 'Group 2'. I have a parameter called Term. If Term = 'All' then only show Group 1 records, otherwise show Group 2. I am trying to set up a filter to do this, but it seems I need it to be like IF-THEN-ELSE. I have the filter here, but how do I now tell it to only show the Group 1 records ELSE Group 2?

enter image description here

I have two ideas and I'm not sure if either are possible or how to do them. Maybe one of you has an idea.

1.) Could I put a CASE in my WHERE clause? Something along the lines of this? SQL Server says this is bad syntax because of the extra = operators.

WHERE CASE WHEN @Term = 'All' THEN j.SetGroup = 'Group 1' ELSE j.SetGroup = 'Group 2' END

2.) Could I put IIF formulas in the Expression and in the Value boxes of my filter with the bottom playing off the top one?

Upvotes: 1

Views: 765

Answers (1)

user3691608
user3691608

Reputation: 47

I knew it there was a simple solution in there somewhere.

WHERE j.SetGroup = CASE
    WHEN @Term = 'All' THEN 'Group 1'
    ELSE 'Group 2'
END

Upvotes: 1

Related Questions