如何检查是否在多值参数中选择了一个值

问题描述:

在 SSRS 2008 中,我使用多值参数为特定参数选择多个值.

In SSRS 2008, I use Multi-value parameters to, well, select multiple values for a particular parameter.

在我的报告中,我有条件格式:如果项目被选中,特定标签必须为蓝色;否则它会保持黑色.我的直觉是用 SQL 方式尝试它 - 但我错了 :-)

In my report I have conditional formatting: a particular label has to be blue if the item is selected; otherwise it will stay black. My intuition was trying it the SQL way - but I was wrong :-)

Switch(
  Fields!groupType.Value = "firstValue", "#00ffffff",
  Fields!groepType.Value = "secondValue", "Tomato",
  Fields!groepType.Value = "thirdValue", "DimGray",
  Fields!groepType.Value IN Parameters!p_myMultipleValueParameter.Values, "Blue"
)

处理这个问题的正确方法是什么?

What is the right way to handle this?

我认为最简洁的方法可能是以下

I think the cleanest way is probably the following

Array.IndexOf(Parameters!p_myMultipleValueParameter.Value, Fields!groepType.Value) > -1

由于分配额外字符串的开销,每次运行连接可能效率低下,特别是如果函数将在一个大列表上运行,或者每行一次网格,例如.

Running a join each time may be inefficient because of the overhead of allocating extra strings, especially if the function will be run over a large list, or once per row of a grid, say.