5

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.

Maffelu
  • 2,018
  • 4
  • 24
  • 35

4 Answers4

3

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.

nzic
  • 184
  • 9
  • nzic: CDec(Sum(Fields!Amount.Value)) gives me #Error. Is there a way to see what value is being parsed? The values are populated in the rows above, so they are obviously valid decimal figures. Except if the wrong culture is being used. – Maffelu Sep 09 '12 at 11:13
  • Are there maybe some null-s that interfere with your sum function? – nzic Sep 09 '12 at 11:16
  • Any null value would show in the report, so no. There are 5 values, -269,53, -274,27, -160,00, -205,00 and -62,60. That's it. – Maffelu Sep 09 '12 at 11:17
  • Well, the problem was in the CDec function, but I don't know why. See my answer. The data was sent as string in the DataTable, but the CDec should've been able to parse it... – Maffelu Sep 09 '12 at 11:27
  • Did you try to format the details row as in =CDec(Fields!Amount.Value) – nzic Sep 09 '12 at 11:29
  • 1
    Yes, gave the same wrongful data as the initial result (97,140.00) – Maffelu Sep 09 '12 at 11:34
2

This solution worked for me. Try this

=ROUND(Sum(Fields!Outros.Value, "DataSet1"),2) 
1

Solved problem as the error was in the datatable. As I was generating the datatable to throw in I didn't set the DataColumn type, so they all defaulted to string. For some reason CDec() and FormatNumber() didn't work even though they were handled as string by the datatable.

Anyhow, after properly creating the datatable with the correct data types for each column it worked.

Maffelu
  • 2,018
  • 4
  • 24
  • 35
0

Try this expression, it worked for me:

=Format(Sum(CDec(Fields!Outros.Value)),"#,##0.00")
miken32
  • 42,008
  • 16
  • 111
  • 154