Search code examples
vbavisual-studioreporting-services

SSRS - Visual Studio round issue


I hope this question is not so stupid. We have an expression column which need to be rounded to 3 decimals. Like, if the expression's result = 0.1805, then round to 0.181, if the expression's result = 0.1804, then round to 0.180. At the same time, if the expression's result = 0 , then show 0.

The thing is that, right now, round(0.1805,3)=0.18 instead of 0.181, which I don't know why. If I change the column's properties to show 3 decimal, then it will show the expression round(0.1805,3) as 0.181, but it would also show 0 as 0.000 which we don't want to. Does anyone has any idea that why the round(0.1805,3)=0.18 here instead of 0.181, while round(0.1806,3)=0.181 which is correct. Thanks a lot! enter image description here


Solution

  • That's because Round performs Banker's Rounding.

    You may have to use Format (or ToString) which does true 4/5 rounding.

    Format(0.1805, "0.000")
    -> 0.181
    

    If not only for display, convert that to decimal or currency.