Rounding Numbers in a Calculated Field

2 posts, 0 answers
  1. Macy
    Macy avatar
    1 posts
    Member since:
    Aug 2017

    Posted 08 Aug 2017 Link to this post

    Bit of a newbie to Telerik Reporting.  I am working in the standalone Report Designer, and I have been digging around for a way to round values in a calculated field but cannot find anything supported by Telerik.  For example:

    I'm trying to calculate the total amount owed by creating a calculated field that uses the following logic: Net Weight * Rate = Amount Owed.  However, I am trying to establish a way for the rounding to be consistent every time (I have several different reports, and sometimes the differences in rounding will lead to discrepancies between reports).

    I have also tried using this formula, but I'm still seeing discrepancies in my reports: = Round( (Fields.UnitPrice * Fields.NetWeight*100) / 100).  Additionally, I tried using the VB Script function FormatNumber but I received an error saying this was an undefined function (is it possible to define your own functions?).  Simply formatting the field as a number did not help, either.

    I need to find a way to tell Telerik to round to two decimal places, but I need it to round either up or down depending on the value so using Floor() and Ceiling() are not going to help.

    Thanks in advance!

  2. Todor
    Todor avatar
    175 posts

    Posted 10 Aug 2017 Link to this post

    Hello Macy,

    To round a number to two decimal places you could use the Format property of the calculated field and set it to Number (or Currency) with Decimal places equal to 2. This automatically performs standard math rounding depending on the third digit after decimal point. You could see this in the attached report (needs to be unzipped first).

    If this formatting doesn't help, you could import custom function to do the rounding. I refer you to the article How To Use User Defined Functions in the Stand-Alone Telerik Report Designer tool that explains how to do it. Note that external functions (including VB) are not directly supported by the standalone Report designer and should be imported as described in the article.

    If you need further assistance, please, send us example reports showing the discrepancies in the calculated field, so we can advise you accordingly.

    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top