Search code examples
sqlreporting-servicesssrs-2008

An SQL statement into SSRS


I tried to incorporate the following into SSRS but failed.

If XXX = “A” then display “AT”

Else if XXX = “B” then display “BEE”

Else if XXX = “C” then display “CAR”

Else display “Other”

I tried

=Switch(
  Fields!XXX.Value = "A", "AT", 
  Fields!XXX.Value = "B", "BEE",
  Fields!XXX.Value = "C", "CAR", "Other")

Solution

  • You almost had it. For every output in the Switch function must be paired with a condition. Just make your last condition evaluate to True.

    =Switch(
      Fields!XXX.Value = "A", "AT", 
      Fields!XXX.Value = "B", "BEE",
      Fields!XXX.Value = "C", "CAR", 
      True, "Other"
    )