views:

642

answers:

2

Hi, 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

+2  A: 

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)
Mark Byers
Updated answer - just realised that AwayFromZero is what you want.
Mark Byers
Thanks, I will try this. I was puzzeled because I read the documentation and when I tried MidpointRounding.AwayFromZero the code was underlined as wrong. Anyway, I will give it a try...
Marcos Buarque
Awayfromzero worked for me, but the red-underlined was still there. Where do I place the import System? Thank you for the help.
Marcos Buarque
using System, sorry... or just be explicit: System.MidpointRounding.AwayFromZero
Mark Byers
+1  A: 

Use the MidpointRounding.AwayFromZero option:

Round([calculated number], [num decimal places], MidpointRounding.AwayFromZero)
slugster
Thanks, I will try this and let you know.
Marcos Buarque