2011-02-02 98 views
4

做一个表达式我得到一个错误,有人可以在这里看到我正确的语法吗?SSRS报告 - IIF声明问题

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

告诉我们是什么错误的机会吗? – 2011-02-02 20:56:07

回答

6

如果你想这一切是一个表情,你可能需要使用switch语句:

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

switch语句将返回值是true.Using的首要条件你的榜样,你可以尝试:

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

另一个不那么优雅的方式将你的窝IIF语句

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

你也可以做你的逻辑在查询:

CASE t_cpcp WHEN '310' THEN 'Purchased Material & Raw Material' 
      WHEN '320' THEN 'Manufacturing Direct Labor' 
      WHEN ... THEN .... 
      ELSE '' 
END as t_cpcp_DESC