Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Reporting Services Round() function

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

like image 496
Marcos Buarque Avatar asked Feb 04 '10 19:02

Marcos Buarque


People also ask

What is ROUND() function?

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.

How do I round to 2 decimal places in SQL Server?

SQL Server ROUND() Function The ROUND() function rounds a number to a specified number of decimal places.

How do you round a field in SQL?

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.


Video Answer


2 Answers

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)
like image 67
Mark Byers Avatar answered Oct 05 '22 16:10

Mark Byers


Use the MidpointRounding.AwayFromZero option:

Round([calculated number], [num decimal places], MidpointRounding.AwayFromZero)
like image 34
slugster Avatar answered Oct 05 '22 14:10

slugster