簡體   English   中英

SSRS報告 - IIF聲明問題

[英]SSRS Report - IIF statement Question

做一個表達式我得到一個錯誤,有人可以在這里告訴我正確的語法嗎?

=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語句:

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

另一個不太優雅的方法是嵌套你的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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM