tomdemaine
tomdemaine

Reputation: 758

Using SWITCH on a parameter that allows multiple values (report builder 3.0)

I am trying to build a little dynamic expression that changes a word in my report based on the parameter chosen. I followed along with this question and answer

Report Builder 3.0 SWITCH expression DEFAULT/ELSE

with the expression

=Switch 
(
  Parameters!LineCalled.Value = "01156842190","Order Line",
  Parameters!LineCalled.Value = "01156842191","Overflow Line",
  true, "Both Lines"
)

but I got #Error when it ran. I think the reason is that by default my parameter picks both of the possible options (order and overflow). Is there a way to write a SWITCH (or I guess some nested iifs) such that it will detect a primary option a secondary option and a third case where both options are picked and change the words shown accordingly?

EDIT :

As per request I have added a view of the available and default values for my parameter.

available

default

Upvotes: 1

Views: 1299

Answers (1)

AnkUser
AnkUser

Reputation: 5531

As mentioned in your edit, you have multi select parameter. Assuming form your parameter you have 2 values 01156842190" and "01156842191 Parameters!LineCalled.Count will give your count if you have selected 2 values or 1 or all.

In your case 2 is All which is also your default.

Below expression will get you desired result

=IIF(Parameters!LineCalled.Count<>2,IIF(Parameters!LineCalled.Value(0) = "01156842190","Order Line","Overflow Line"),"Both Lines")

Upvotes: 1

Related Questions