【问题标题】:How to format a number with an expression in SSRS based on a value?如何根据值在 SSRS 中使用表达式格式化数字?
【发布时间】:2013-06-15 13:52:58
【问题描述】:

我的 SSRS 2012 报告的数据集中有名为 priceminIncrement 的字段。我想使用基于minIncrement 字段的表达式来格式化price。例如,如果price94.95000minIncrement0.01,那么我希望price 在报告中显示为94.95。如果price12345.000000minIncrement1,则将price 显示为12345

有没有办法做到这一点?可能的minIncrement 值是

0.000100
0.010000
0.100000
0.250000
1.000000

【问题讨论】:

    标签: sql-server reporting-services sql-server-2012 ssrs-2012 reporting-services-2012


    【解决方案1】:

    您可以创建一个表达式,例如:

    =Format(
        Fields!Price.Value, 
        Switch(
            Fields!MinIncrement.Value = 0.000100, "0.0000",
            Fields!MinIncrement.Value = 0.010000, "0.00",
            Fields!MinIncrement.Value = 0.100000, "0.0"
        )
    )
    

    只需使用 MinIncrement 的其他可能值扩展 Switch 语句即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-29
      相关资源
      最近更新 更多