How do I get multiple integers into the value field of an SSRS parameter so that I can use an IN statement in my WHERE clause?
Bear with me. I think this will end up as a simple syntax question but the explanation is overlong.
I have a report that I want to split between two types of staff Dedicated and Bureau. The only way to determine which is which is the hour that the activation occurs, with the dedicated staff working all hours except 12 and 13 (midday to 2pm).
I've created a parameter called @AgentType and added a where clause in my SQL query
Where
[Hour] in (@AgentType)
I then set the data type of the parameter as an Integer and set the available values as in the picture.
This works perfectly as a test however if I try to model the working hours accurately
SSRS removes my commas and turns the interger into 1234567... Also I tried using an expresion =1,2,3... but that caused errors when the report ran.
So my question basically is how do I get multiple integers into the value field of an SSRS parameter so that I can use an IN statement in my WHERE clause?
This solution could work for you. You can create two parameters, AgentType
and AgentTypeHidden
.
For AgentType
set two available values as follows:
AgentTypeHidden
must be hidden and set to allow multiple values:
Don't set any available values but default values using this expression:
=IIF(
Parameters!AgentType.Value=1,
SPLIT("1,2,3,4,5,6,7,8,9,10,11,14",","),
SPLIT("12,13",",")
)
Also set Always Refresh
for the AgentTypeHidden
parameter.
Finally in your query use the AgenTypeHidden
parameter.
Where [Hour] in (@AgentTypeHidden)
Let me know if this helps.