SSRS报告 - IIF声明问题

Gab*_*lVa 5 sql if-statement reporting-services ssrs-2008

做一个表达式我得到一个错误,有人可以在这里告诉我正确的语法吗?

=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)
Run Code Online (Sandbox Code Playgroud)

Joe*_*ham 9

如果您希望这一切都在一个表达式中,您可能需要使用SWITCH语句:

=Switch(<condition>, <return value if true>, <next condition>, <return value if true>, ...)
Run Code Online (Sandbox Code Playgroud)

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...)
Run Code Online (Sandbox Code Playgroud)