SSRS expression equivalent to case statement in sql


I have a simple employee table where a column is departname, and i am trying to add a derived column named 'Location', based on the following sql expression,Can you please help me how to write the below code as an ssrs expression?.
I tried with iif , but no progress

case when departname='Research' then 'Boston'

case when departname='Sales then 'Saint Louis'

case when departname='IT' then 'Newjersey'

1 Answer

You should be able to do this with iif (although you would need to nest a second iif inside the expression, as you have three options), but switch would probably be more suitable - something like:

=Switch(Fields!departname.Value = "Research","Boston", Fields!departname.Value = "Sales","Saint Louis", Fields!departname.Value = "IT","Newjersey")

(Note the use of double quotes rather than single quotes.)

Alternatively, you could add your SQL Case expression to your query as another column.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like