Avg option for Row::sumRow


#1

Hi, would it be possible to add an average parameter to the column aggregation meta data for function the sumRow function of the Row class?
I have no idea how to calculate average metrics otherwise.


(Matthieu Aubry) #2

what is your use case and issue?

I looked into getColumnValuesMerged matomo/Row.php at master · matomo-org/matomo · GitHub but maybe adding ‘avg’ would not work

in general to process average you need all the values, and then sum them and divide by number of values. Something like:


$values = $table->getColumn('metric');
$average = array_sum($values) / count($values);


#3

Recapitulizing the whole thing, I will better do it with the CollumCallbackAddColumnQuotionen filter :slight_smile: