C# – Using SUM in an RDLC report on decimal gives weird result

crdlc

I'm trying to generate an RDLC report where one column, Amount, is going to have a "Total" row at the bottom. This isn't weird stuff, it's a very basic RDLC report, but instead of getting the normal "Total" value at the bottom I get something else, allow me to demonstrate:

enter image description here

It shouldn't say 97,140.00, it should say 971,40 so I'm a bit confused. The column is summarized like this:

=Sum(CDec(Fields!Amount.Value))

I have to convert it first for some reason otherwise I get an #Error instead of the wrong number. This is weird as well as the model property is a decimal and the DataTable property I'm using is a decimal.

My only guess is that it has something to do with me being swedish and using comma as decimal separator instead of a period.

Best Answer

The problem is obviously in CDec function. If you are sure that there is no other way for not using CDec try this: CDec(Sum(Fields!Oil_Gas.Value)) or this: FormatNumber(CDec(Sum(Fields!Oil_Gas.Value)),2) or this: FormatNumber(Sum(Fields!Oil_Gas.Value),2)

I couldn't really reproduce your problem but all mentioned solutions works for me.

Related Topic