在SSRS表达式中转换*字符

时间:2018-07-05 08:18:36

标签: reporting-services character expression

我在SSRS中使用以下表达式

=IIF(ReportItems!Textbox69.Value = "~*", 
        "Excellent", IIF (ReportItems!Textbox69.Value = 1,
        "Very Good", IIF (ReportItems!Textbox69.Value = 2,
        "Good", IIF (ReportItems!Textbox69.Value = 3,
        "Modest", "Cause for Concern")
        )
        )
    )

运行报表时,所有带有*的字段最初都作为错误出现。我该如何转换这个字符?

1 个答案:

答案 0 :(得分:0)

由于您的文本框包含字符串,因此您必须在比较中使用引号

=IIF(ReportItems!Textbox69.Value = "*", 
        "Excellent", IIF (ReportItems!Textbox69.Value = "1",
        "Very Good", IIF (ReportItems!Textbox69.Value = "2",
        "Good", IIF (ReportItems!Textbox69.Value = "3",
        "Modest", "Cause for Concern")
        )
        )
    )

我还建议考虑使用Switch而不是嵌套的Iif

= Switch(
ReportItems!Textbox69.Value = "*", "Excellent",
ReportItems!Textbox69.Value = "1", "Very Good", 
ReportItems!Textbox69.Value = "2", "Good", 
ReportItems!Textbox69.Value = "3", "Modest", 
True,"Cause for Concern"
)