SSRS报告-IIF声明问题

问题描述:

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

Doing an expression I get an error, can someone show me the correct syntax here?

=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)

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

If you want this to all be in one expression, you may want to use the SWITCH statement:

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

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

The switch statement will return the value for the first condition that is true.Using your example, you could try:

=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...)