RDLC Switch Construct - is there an Else?

m.edmondson picture m.edmondson · Jun 21, 2012 · Viewed 16.1k times · Source

I have the following expression within a report:

= Switch( Fields!RATE_CODE.Value = "First", " £/Week",
          Fields!RATE_CODE.Value = "Second", " £/Day")

I've searched all over but cannot find a way to add an else or default to this expression. There doesn't seem to be any doc's on this contruct either.

Is this possible?

Answer

Marek Grzenkowicz picture Marek Grzenkowicz · Jun 21, 2012

The Switch function returns the value associated with the first expression in a series that evaluates to true, you can use the following trick:

= Switch( Fields!RATE_CODE.Value = "First" , " £/Week",
          Fields!RATE_CODE.Value = "Second", " £/Day",
          1 = 1,                           , "default value" )