2011-02-02 134 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