Search code examples
reporting-servicesssrs-2008ssrs-2008-r2

Strip decimals in SSRS expression without rounding


In my report I'm trying to remove the decimals without rounding. I'll be using this to set the minimum value in the vertical axis of the area chart.

So I tried =Format(98.56, "N0"), but this returns 99, which is incorrect. It should return 98.

I've been searching specifically for SSRS, but most of the results are for tsql.

My question: How can I remov decimals in SSRS without rounding?

Thanks


Solution

  • Try using "Floor". It effective rounds down to the nearest integer. You'll find this under the Math functions.

    =Floor(Fields!Number.Value)
    

    Note, there's also a Floor function in Transact-SQL that works the same way in case you need to do some of the processing in your SQL script.

    Update based on request in comments If you wanted to achieve the same result after the decimal point, all you need is a little algebra.

    =Floor((Fields!Number.Value*10))/10
    

    That should turn 99.46 into 99.4. Given that it shaves off the remainder, you could then tack on any additional zeroes you wanted.