首页 > 解决方案 > Converting * character in SSRS Expression

问题描述

I am using the following expression in 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")
        )
        )
    )

When I run my report, all the fields that had a * originally are coming up as an error. How can I convert this character please?

标签: reporting-servicescharacterexpression

解决方案


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

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

推荐阅读