there is some bizarre thing happening with my report generated in SQL Server Reporting Services and I hope I am not being too stupid. I use the Round function to get integers. Sometimes a 4.5 will round to 4 and a 5.5 will round to 6. Is this because of the rounding method? I am using this:
Round(Fields!GroupAverageAssessment.Value,0)
How can I make a regular rounding (4.5 to 5, 3.5 to 4, 6.5 to 7 and so on...)
Thanks
The ROUND function rounds a number to a specified number of digits. For example, if cell A1 contains 23.7825, and you want to round that value to two decimal places, you can use the following formula: =ROUND(A1, 2) The result of this function is 23.78.
SQL Server ROUND() Function The ROUND() function rounds a number to a specified number of decimal places.
If you'd like to round a floating-point number to a specific number of decimal places in SQL, use the ROUND function. The first argument of this function is the column whose values you want to round; the second argument is optional and denotes the number of places to which you want to round.
It sounds like round to even, also known as Banker's rounding.
The other option is "away from zero", which is what you want:
Round(4.5, 0, MidpointRounding.AwayFromZero)
Use the MidpointRounding.AwayFromZero
option:
Round([calculated number], [num decimal places], MidpointRounding.AwayFromZero)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With