Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Average of sum

I am looking for one way to get an average of sum. I tried avg(sum(fieldname)) and in return I got only 0.

In my example I got car inspeccions done and I want to know in average how much I do by hour for instance.

My data is loaded inspeccion by inspeccion and has got all the information concerning the exact time it is done.

thanks in advance for the help,

afonso

Labels (1)
4 Replies
jfkinspari
Partner - Specialist
Partner - Specialist

You could use the aggr function. Let's say you want to calc the avg of some sum per hour that would be

avg(aggr(sum(Fieldname),HourFieldname))

The aggr function gives you a list of values calculated by HourFieldname, which you then calculates the avg of.

hic
Former Employee
Former Employee

This is a nested aggregation. You first want to sum the costs per inspection. Then you want to calculate some average. For instance the average cost per inspection would be

     Sum(Cost)/Count(distinct Inspection)

or

     Avg(Aggr(Sum(Cost), Inspection))

How you want the number of hours to influence the calculation I am not sure. Perhaps

     Sum(Cost)/Sum(Hours)

and use Inspection as dimension?

HIC

Not applicable
Author

Aggr(Sum(Cost), Inspection) / Count(distinct Inspection)

Not applicable
Author

thanks for your tip.

I tried using aggr function but it didn't work as I was expecting. I end up dividing sum (receptions) by count (distinct calendardate) and it work perfectly.