SSRS expression equivalent to case statement in sql

試著忘記壹切 提交于 2020-01-25 04:54:41

问题



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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!