简体   繁体   中英

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

=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. It is working fine, But not for Multi parameter. 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.

The first one Parameters.Input,Value = "0","Zero", would work if, as you said, the parameter was not multi-value. 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. 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.

You can use VB functions like Contains() to search parameters if you really need to. 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 | symbol, into a string, then search for the text you are interested in using Contains() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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