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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
pascaldijkshoor
Creator
Creator

Aggr Function

Hi Guys,

I am struggling with an aggr function. I think in theory the formula i use should be right but somehow it does not work. I am calculating the driven kilometers of trucks with the following formula: Max (Mileage) - Min (Mileage), and this works fine. Every truck is linked to a department. Now i want to make a pivottable with department as a dimension and a certain timefield (date/week/month etc.) as a dimension.

The measure should calculate for every truck separately the driven kilometers and then calculate the average of all trucks per department. I tried to use this formula but it doesn't work:

avg (aggr ((Max (MILEAGE)-Min (MILEAGE)),ASSET_NR_LINKED))

Whereby ASSET_NR_LINKED is the dimension for the different trucks.

Anyone who can help me?

1 Solution

Accepted Solutions
marcus_sommer

You mentioned that the expression should work in context with "... certain timefield (date/week/month etc.) ...". This meant you need also to add these time-fields to your aggr. If this didn't work it would be helpful to know with which numbers do you expect which output and which you get from your expression.

- Marcus

View solution in original post

6 Replies
sunny_talwar

Could a single truck land up in more then one Department or is there a one to one relation between Department and truck? If it is not one to one, then may add Department to your Aggr() function

Avg(Aggr((Max(MILEAGE) - Min(MILEAGE)), Department, ASSET_NR_LINKED))

pascaldijkshoor
Creator
Creator
Author

No a single truck is only linked to one department, so this is not the case.

sunny_talwar

Have you still tried this?

Avg(Aggr((Max(MILEAGE) - Min(MILEAGE)), Department, ASSET_NR_LINKED))

pascaldijkshoor
Creator
Creator
Author

Yeah i tried, but the result is exactly the same.

marcus_sommer

You mentioned that the expression should work in context with "... certain timefield (date/week/month etc.) ...". This meant you need also to add these time-fields to your aggr. If this didn't work it would be helpful to know with which numbers do you expect which output and which you get from your expression.

- Marcus

pascaldijkshoor
Creator
Creator
Author

Thanks Marcus, the addition of the timefield seems to solve the problem