Sum function round to zero decimal places

12 posts, 0 answers
  1. Francisco
    Francisco avatar
    7 posts
    Member since:
    Aug 2008

    Posted 09 Feb 2011 Link to this post

     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

  2. Sumit
    Sumit avatar
    9 posts
    Member since:
    Apr 2011

    Posted 13 Feb 2012 Link to this post

    Hi,
    I also have the same problem (when using Sum(Iif()), value gets rounded).
    Do you have any solution?
    Regards,
    Sumit
  3. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 13 Feb 2012 Link to this post

    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.

    Looking forward to your reply.

    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 >>
  4. Sumit
    Sumit avatar
    9 posts
    Member since:
    Apr 2011

    Posted 13 Feb 2012 Link to this post

    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. 
  5. Marlon
    Marlon avatar
    1 posts
    Member since:
    Jan 2012

    Posted 16 Feb 2012 Link to this post

    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 
  6. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 17 Feb 2012 Link to this post

    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 >>
  7. Divya
    Divya avatar
    9 posts
    Member since:
    Mar 2014

    Posted 10 Apr 2014 in reply to Steve Link to this post

    =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
  8. akin
    akin avatar
    6 posts
    Member since:
    Mar 2015

    Posted 03 Mar 2015 in reply to Steve Link to this post

    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?

  9. akin
    akin avatar
    6 posts
    Member since:
    Mar 2015

    Posted 03 Mar 2015 in reply to Steve Link to this post

    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?
  10. Hinata
    Hinata avatar
    146 posts
    Member since:
    Dec 2013

    Posted 05 Mar 2015 in reply to akin Link to this post

    Hi akin,

    Yes, you can use multiple IIf functions inside and add them together.
  11. Pr@moD
    Pr@moD avatar
    1 posts
    Member since:
    Apr 2015

    Posted 13 Apr 2015 Link to this post

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

    please suggest.

    thanks

  12. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 16 Apr 2015 Link to this post

    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.

     
Back to Top