简体   繁体   English

SSRS 表达式中 Switch 案例中的多值参数

[英]Multi value Parameter in side a Switch case in SSRS Expression

I have Multivalve Parameter with defined value As String in the Parameter, All I want to show in the report Header based on the value selected Needs to show the text based on the Switch condition我有 Multivalve 参数,在参数中定义为字符串,我想根据所选值在报告 Header 中显示所有需要根据切换条件显示文本

=switch(
Parameters!Input.Value = "0","Zero",
Parameters!Input.Value = "1", "One"
Parameters!Input.Value = "2", "Two"
Parameters!Input.Value = "3", "Three"
True, "OTHER"
)
=switch(
Parameters!Input.Value(0) = "0","Zero",
Parameters!Input.Value(1) = "1", "One"
Parameters!Input.Value(2) = "2", "Two"
Parameters!Input.Value(3) = "3", "Three"
True, "OTHER"
)

I have tried both ways, Order of the parameter values are same as in the switch condition.这两种方法我都试过了,参数值的顺序与开关条件下的相同。 When run #Error, When Change Multi to single value parameter.运行 #Error 时,将 Multi 更改为单值参数时。 It is working fine, But not for Multi parameter.它工作正常,但不适用于 Multi 参数。 Inputs will be appreciated.输入将不胜感激。 Thank you谢谢

I may have misunderstood but it sounds like you just want to list the labels of the selected parameters in a text box?我可能误解了,但听起来您只想在文本框中列出所选参数的标签?

If that's the case then that's pretty simple.如果是这样的话,那就很简单了。

=JOIN(Parameters!Input.Label, ", ")

If this is not what you wanted then you'll have to clarify exactly what you want to do but let's look at your switch statements and understand why they don't work.如果这不是您想要的,那么您必须明确说明您想要做什么,但让我们看看您的 switch 语句并了解它们为什么不起作用。

The first one Parameters.Input,Value = "0","Zero", would work if, as you said, the parameter was not multi-value.第一个Parameters.Input,Value = "0","Zero",如果如您所说,参数不是多值,则将起作用。 It won't work when the parameter is multi-value because you are then trying to compare an array with a string.当参数是多值时它不起作用,因为您正在尝试将数组与字符串进行比较。

The second one Parameters.Input,Value(0) = "0","Zero", might work is all values are selected but not if only 3 or less are selected.第二个Parameters.Input,Value(0) = "0","Zero",可能会选择所有值,但如果只选择3个或更少,则不会。 The Parameters collection stores the selected values, therefore, if you only chose say "3" then Parameters.Input.Value(0) would contain "3" as it's the first selected item. Parameters 集合存储选定的值,因此,如果您只选择说“3”,则Parameters.Input.Value(0)将包含"3" ,因为它是第一个选定的项目。

You can use VB functions like Contains() to search parameters if you really need to.如果确实需要,可以使用Contains()等 VB 函数来搜索参数。 It's a bit messy but it would work.这有点乱,但它会工作。

("|" & JOIN(Parameters!Input.Label, "|") & "|").Contains("|Two|")

Here we get an array of all selected parameter labels, JOIN each element separated by a pipe |这里我们得到一个包含所有选定参数标签的数组, JOIN每个元素由 pipe |分隔。 symbol, into a string, then search for the text you are interested in using Contains() .符号,转换为字符串,然后使用Contains()搜索您感兴趣的文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM