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

tomdemaine
  • 738
  • 6
  • 22
  • Is your parameter multiselect? What is "Both Lines" do you mean when user selects both values it should add both "Order Line", and "Overflow Line", Could you show us your report design w.r.t Parameter. – AnkUser Sep 04 '19 at 14:07
  • Yes it is multi select. By default it selects both and I want that to be translated to "Both lines" in my text expression. – tomdemaine Sep 04 '19 at 14:11

1 Answers1

1

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")
AnkUser
  • 5,421
  • 2
  • 9
  • 25
  • 1
    Thanks for this. One comment, when I used your exact syntax is still threw a #Error. I fixed it by using Parameters!LineCalled.Value(0) instead of simply Parameters!LineCalled.Value. Not sure why but this worked. – tomdemaine Sep 04 '19 at 15:28