You could do this the way you want but I would approach this differently as it's easier to see what's going on especially if this gets passed to somebody else to debug later.
There are two ways of doing this. The first is to pass in a single value for Close or Open and then add some logic to the dataset
DECLARE @s TABLE(status char(10))
IF @states = 0 -- Closed
BEGIN
INSERT INTO @s VALUES('c'),('p')
END
ELSE
BEGIN
INSERT INTO @s VALUES('o')
END
select * from myTable a
JOIN @s s on a.status = s.status
I realise it's more code but it's simple to follow.
IF THIS WORKS FOR YOU STOP READING NOW !!
The second option (assuming you don't want your users to just be able to select 'c' or 'p' individually) it a bit more effort to set up only the SSRS side but the SQL is very simple. Don't be put off by the length of the answer it actually pretty simple.
Your dataset query would just look something like this...
select * from myTable a WHERE a.Status in (@status)
In your report design set the @states
parameter available values to c
, p
and o
as separate items and make the parameter multi-value.
At this point you should be able to test that the report works and you can select 1, 2 or all three options and get the relevant results, there is no need for joins splits or anything else, it will just work.
Now, as I assume you don't want your users to be able to choose at this level, we need to make some changes.
First add a new dataset called say dsDefaultStatus
and set the query to something like
DECLARE @s TABLE(status char(10))
IF @status = 0 -- Closed
BEGIN
INSERT INTO @s VALUES('c'),('p')
END
ELSE
BEGIN
INSERT INTO @s VALUES('o')
END
SELECT * FROM @s
You should new have a new @status
parameter. Give this two available labels/values such as 'Close'=0 and 'Open'=1 to match the query above.
Now go back to the @states
parameter and change the default values to dsDefaultStatus
, you can then hide this parameter if required.
As the user selects the Open/Close status in the first parameter, the defaults selection for this hidden parameter will change. When you run the report the values from the hidden parameter get passed to the report.