# Sum function round to zero decimal places

General Discussions
Top achievements
Rank 1
Francisco asked on 10 Feb 2011, 12:45 AM
Hi,
i have a problem with sum function on a textbox, this function round the values to zero decimal places.
i use the Q2 2010 version.
please see this exemple on images.

best reguards,
Francisco

## 11 Answers, 1 is accepted

0
Sumit
Top achievements
Rank 1
answered on 13 Feb 2012, 06:43 AM
Hi,
I also have the same problem (when using Sum(Iif()), value gets rounded).
Do you have any solution?
Regards,
Sumit
0
Steve
Telerik team
answered on 13 Feb 2012, 10:01 AM
Hello Sumit,

We have not been able to reproduce such behavior on our end and would appreciate if you open a support ticket and attach a runnable sample report that shows the problematic behavior. Note that we do not need your actual data and some dummy data and report would suffice, as long as it exhibits the issue.

Regards,
Steve
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Sumit
Top achievements
Rank 1
answered on 14 Feb 2012, 02:44 AM
Hi Steve,

I am sorry, I will not be able to attach a sample this time.

But if you use decimal numbers and generate simple total using Sum(Field.A), it works fine.
However, Sum(Iif(Field.A>0,Field.A,0)) generates sum by rounding of the decimal digits.

Also, if Field.A has only one data (eg 14.10), then returned Sum is 14.10 (decimal not rounded);
but if it has two or more data to sum (eg 14.10 and 100.00), then the returned sum is 114.00 (decimal rounded).

Hope this helps.

Thanks,
Sumit

PS: I have worked around by altering my SQL statement (by using CASE..END) so that I do not have to use Sum(Iif()) in my report.
0
Marlon
Top achievements
Rank 1
answered on 16 Feb 2012, 04:22 PM
Hello,
For those doubting the round of the sum I could solve it this way:

= Sum (IIf (Fields.IvaNumber = 2, CDbl (Fields.Value), 0.00))

I did that and I rounded the number to zero, leaving him with decimal

Sorry for my English, I'm from Colombia: D
0
Steve
Telerik team
answered on 17 Feb 2012, 08:37 AM
Hi guys,

Thank you for the clarification first, now it is clear. As Marlon correctly found out, making the second parameter of the same type works as expected. You see the IIF functions has 2 parameters that in your case are of different types. The Sum aggregate on the other hand receives as value an array of different types, so it needs to fall back to one of the types. As the reporting engine evaluates both function parameters of IIF function and then passes the result values to the function, it would take the type of the first parameter that is evaluated i.e. if in Marlon's expression the first database record Fields.IvaNumber is 2, then it would take the type of the True parameter of the IIF function, namely Double.

Making sure the parameters are of the same type when aggregating is essential, so you can use the built-in cast functions or specify explicitly a value to be of certain type (i.e. 0.00).

Kind regards,
Steve
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Divya
Top achievements
Rank 1
answered on 10 Apr 2014, 07:16 AM
=round(sum(Fields.attend)/IIF(sum(Fields.absentcount)+sum(Fields.attend)=0,1,
sum(Fields.absentcount)+sum(Fields.attend))*100,2) d in rdlc report

replace to telerik reporting error occur solution for this
0
akin
Top achievements
Rank 1
answered on 03 Mar 2015, 10:43 AM
With regards to Marlon's post
= Sum (IIf (Fields.IvaNumber = 2, CDbl (Fields.Value), 0.00))
How would I be able to round multiple numbers from one query?

0
akin
Top achievements
Rank 1
answered on 03 Mar 2015, 10:44 AM
With regards to Marlon's post
= Sum (IIf (Fields.IvaNumber = 2, CDbl (Fields.Value), 0.00))
Would it be possible to apply this to a row which has more than one result of numbers?
0
Hinata
Top achievements
Rank 1
answered on 05 Mar 2015, 03:39 PM
Hi akin,

Yes, you can use multiple IIf functions inside and add them together.
0
Pr@moD
Top achievements
Rank 1
answered on 13 Apr 2015, 11:39 AM

we are using telerik reporting and in telerik Sum aggregate function not working.

thanks

0
Stef
Telerik team
answered on 16 Apr 2015, 08:57 AM
Hello Pr@moD,

The following expression, used as a Value of a TextBox item in a ReportFooter section, works as expected with Telerik Reporting Q1 2015 SP1 v9.0.15.324:
`{Sum(IIf (Fields.DepartmentID %2=0, CDbl (Fields.DepartmentID), 0.00))}`
Note that the aggregate will be executed based on the current data scope. If you need other scope, test combining the Sum function with the built-in data functions.

If you need further help, please elaborate on the problem e.g. where you use the expression in the report and what is the current and the expected results.

Regards,
Stef
Telerik

See What's Next in App Development. Register for TelerikNEXT.

Tags
General Discussions
Francisco
Top achievements
Rank 1
Sumit
Top achievements
Rank 1
Steve
Telerik team
Marlon
Top achievements
Rank 1
Divya
Top achievements
Rank 1
akin
Top achievements
Rank 1
Hinata
Top achievements
Rank 1
Pr@moD
Top achievements
Rank 1
Stef
Telerik team