如何在 SSRS 表达式中使用 If Else

How to use If Else in SSRS expression

我正在尝试使用 SSRS 表达式计算文本框值。

目前我正在做如下事情:

=IIF(Fields!VariableValue.Value =1,"Pass",IIF(Fields!VariableValue.Value = 2,"Fail",IIF(Fields!VariableValue.Value = 3,"Abort",IIF(Fields!VariableValue.Value = 4,"ByPass",IIF(Fields!VariableValue.Value ="#Error","NA",Fields!VariableValue.Value)))))

有更好的方法吗?

它并不完美,但您可以使用 SWITCH 使其更易于阅读:

=Switch
(
    Fields!VariableValue.Value = 1, "Pass",
    Fields!VariableValue.Value = 2, "Fail",
    Fields!VariableValue.Value = 3, "Abort",
    Fields!VariableValue.Value = 4, "ByPass",
    Fields!VariableValue.Value = "#Error", "NA"
    true, Fields!VariableValue.Value
)

看看你的例子,我不是 100% 确定原来的或新的表达式是否有效(VariableValue 是数字还是文本?)但希望这对你来说是更好的方法。