This topic is locked

Rounding Average

4/14/2018 2:58:55 AM
PHPRunner General questions
K
klawi author

Hi there and greetings from germany,
maybe somebody can help me with a problem printing averages in areport.

At the moment I get this, for example, 15.636363636364
I want to round average(s) to 2 decimals. All the other numbers/days in rows are o.k., just as they are printed (without decimals).

For example, I have a column with the single days. I dont want that rounded to, let´s say, 115.00 days, because there never will be

fractions of the days. Just the "average" of the days at the end should be rounded.
Whatever I tried changes all numbers in the last column.

I hope I could bring my problem across, my english is not too good.

Can everybody offer a solution?
Thanks for your time and best wishes

Werner

admin 4/15/2018

As a simplest example you can use round() function.
Set 'View as' type of the field in question to 'Custom' and use the following code:

$value = round($value, 2);


More info:

http://php.net/manual/en/function.round.php

K
klawi author 4/16/2018



As a simplest example you can use round() function.
Set 'View as' type of the field in question to 'Custom' and use the following code:

$value = round($value, 2);


More info:

http://php.net/manual/en/function.round.php


Thanks for your answer! That is the first thing I tried, but it does not solve my problem.
As I posted: I do not want to round the field itself, I want to round just the average, when

the report is printed!


We are talking about report here and I don´t see any option to set "View as" in the report or in the avg-field.
The fields from the database are o.k. as they are - without decimals. I do not want to change the fields. Just the average sum.



Thanks again for your time and best wishes

Werner