问题
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:
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.
来源:https://stackoverflow.com/questions/36008026/ssrs-expression-equivalent-to-case-statement-in-sql