Nested aggregations
You may come across situations where you need to apply an aggregation to the result of another aggregation. This is referred to as nesting aggregations.
You cannot nest aggregations in most chart expressions. You can, however, nest aggregations if you use the TOTAL qualifier in the inner aggregation function.
Nested aggregations with the TOTAL qualifier
Example:
You want to calculate the sum of the field Sales, but only include transactions with an OrderDate equal to the last year. The last year can be obtained via the aggregation function Max(TOTAL Year(OrderDate)).
The following aggregation would return the desired result:
Sum(If(Year(OrderDate)=Max(TOTAL Year(OrderDate)), Sales))
Qlik Sense requires the inclusion of the TOTAL qualifier this type of nesting. It is necessary for the desired comparison. This type of nesting need is quite common and is a good practice.