Getting multiple integer values in an SSRS parameter

旧城冷巷雨未停 提交于 2019-12-23 03:09:49

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/39638047/getting-multiple-integer-values-in-an-ssrs-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!