【问题标题】:SSRS IIF statement to find if rounding up or downSSRS IIF 语句查找是向上还是向下舍入
【发布时间】:2015-04-15 19:34:51
【问题描述】:

我找到了多种格式化四舍五入数字的方法,但我正在寻找的是如何判断数字的四舍五入方式,特别是在 SSRS 2014 中:

=IIF(Round(Fields!IMPERVIOUS_AREA.Value/4000,2,MidpointRounding.AwayFromZero)=Floor(0),"Round Up","Round Down")

我希望在我的结果中看到 5.73 为“向上取整”,2.09 为“向下取整”,但我得到的只是“向下取整” ”。我尝试将=Ceiling(0)=Floor(0) 放在我的陈述中,希望它可以评估真假。

【问题讨论】:

  • 所以看起来零 (0) 是问题所在。

标签: reporting-services ssrs-2014


【解决方案1】:

Ceiling(value) 总是向上舍入到最接近的整数。 Round(value) 根据通用规则决定采用哪种方式进行舍入。

因此,测试 if Ceiling(value) = Round(value) 将告诉您该值是否被四舍五入。

=IIF(Ceiling(value) = Floor(value), "Value was already an integer.", IIF(Ceiling(value) = Round(value), "Value was Rounded Up.", "Value was Rounded Down."))

【讨论】:

    【解决方案2】:

    您可以比较舍入和未舍入的值。这可以让你看到运动的方向:

    =IIF(Round(value) > value, 
        "Rounded Up",
        IIF(Round(value) < value, 
            "Rounded Down", 
            "No rounding"))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-06
      • 1970-01-01
      • 2014-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-28
      相关资源
      最近更新 更多