reporting-servicesswitch-statementssrs-2008-r2iif-function

SSRS SWITCH Syntax not working


I have a columns in my dataset that will be returning several different values. In an attempt to to use grouping in the report I am trying to clean up the data. After reading several posts I found this post that seemed to be very close to what I needed.

I set up my expressions like this

=SWITCH(
Left(Fields!T6_TOW_BY.Value,3)="ACE","ACE WRECKER",
Left(Fields!T6_TOW_BY.Value,3)="CAR","CAR STORE",
Left(Fields!T6_TOW_BY.Value,7)="THE CAR","CAR STORE",
Fields!T6_TOW_BY.Value

)

The expression does not throw an error when I preview it, but all the columns show "error" Can anyone please show me where I am going wrong here?

Thanks


Solution

  • The Switch statement requires pairs of arguments. You can't just have the last value by itself as an Else condition. Try this:

    =SWITCH(
    Left(Fields!T6_TOW_BY.Value,3)="ACE","ACE WRECKER",
    Left(Fields!T6_TOW_BY.Value,3)="CAR","CAR STORE",
    Left(Fields!T6_TOW_BY.Value,7)="THE CAR","CAR STORE",
    True, Fields!T6_TOW_BY.Value
    )