2 Replies Latest reply: Mar 30, 2018 9:33 AM by Pascal Dijkshoorn

# Sum distinct (Max-Min)

Hi All,

I am calculating the driven kilometers of trucks with the calculation Max (Mileage) - Min (Mileage) and this works fine. Every truck is linked to a department. Now i want to make a chart with department as dimension and summed or average driven kilometers of all trucks in a certain department.

The formulas i tried did not work, because the formula takes from all trucks the truck with the highest mileage and the truck with the lowest mileage.

So the formula needs to calculate the driven kilometers for every truck separately and then sum it up per department.

Anyone who can help me with this?

• ###### Re: Sum distinct (Max-Min)

You probably need to use the Aggr function

Pitfalls of the Aggr function

• ###### Re: Sum distinct (Max-Min)

I tried to use the aggr function, but i dont have any experience with using this function. When I enter the following formula, i only get 0 values:

Sum (aggr (sum ((Max (MILEAGE)-Min (MILEAGE))),ASSET_NR_LINKED,[ACTIVITY_DATE.autoCalendar.Date]))

Anyone who knows what is going wrong? So i want to calculate the driven kilometers per day per truck, and then sum everything.