This is a migrated thread and some comments may be shown as answers.

Rounding Numbers in a Calculated Field

1 Answer 397 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Macy
Top achievements
Rank 1
Macy asked on 08 Aug 2017, 08:46 PM

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!

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 10 Aug 2017, 06:59 AM
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.

Regards,
Todor
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
Tags
Report Designer (standalone)
Asked by
Macy
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or