小编典典

SSRS报告-IIF声明问题

sql

在执行表达式时出现错误,有人可以在此处显示正确的语法吗?

=IIf(Fields!t_cpcp.Value ="310", "Purchased Material & Raw Material", Nothing)
=IIf(Fields!t_cpcp.Value ="320", "Manufacturing Direct Labor", Nothing)
=IIf(Fields!t_cpcp.Value ="325", "Subcontract Cost", Nothing)
=IIf(Fields!t_cpcp.Value ="330", "Engineering Direct Labor", Nothing)
=IIf(Fields!t_cpcp.Value ="340", "Manufacturing Labor O/H", Nothing)
=IIf(Fields!t_cpcp.Value ="345", "Engineering Labor O/H", Nothing)
=IIf(Fields!t_cpcp.Value ="350", "Material O/H", Nothing)
=IIf(Fields!t_cpcp.Value ="355", "Labor O/H Surcharge", Nothing)
=IIf(Fields!t_cpcp.Value ="360", "Subcontract Material Burden", Nothing)
=IIf(Fields!t_cpcp.Value ="MFD", "Manufactured Items", Nothing)

阅读 197

收藏
2021-04-22

共1个答案

小编典典

如果要全部包含在一个表达式中,则可能要使用SWITCH语句:

=Switch(<condition>, <return value if true>, <next condition>, <return value if true>, ...)

switch语句将返回第一个条件为true的值,以您的示例为例,您可以尝试:

=Switch(Fields!t_cpcp.Value ="310", "Purchased Material & Raw Material",
        Fields!t_cpcp.Value ="320", "Manufacturing Direct Labor",
        Fields!t_cpcp.Value ="325", "Subcontract Cost",
        ...rest of them go here...)
2021-04-22