Search code examples
reporting-servicesssrs-2014

SSRS IIF statement to find if rounding up or down


I've found multiple ways to format a rounded number, but what I am looking for is how to tell which way a number is rounded, specifically in SSRS 2014:

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

I would like to see in my results 5.73 to be "Rounded Up" and 2.09 to be "Rounded Down", but all I keep getting is "Rounded Down". I've tried putting =Ceiling(0) and =Floor(0) in my statement, hoping it could evaluate true or false.


Solution

  • Ceiling(value) always rounds up to the nearest integer. Round(value) decides which way to round based on the common rules.

    So it follows that testing if Ceiling(value) = Round(value) will tell you whether the value was rounded up.

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