Think of the aggr() function as making a temporary table. For instance, let's say we have this real table of data:
Customer, Value A, 20 A, 30 B, 10 B, 15 C, 40
Now, as a requirement, let's say that we're looking for maximum value by customer, and then the minimum of THAT value across customers. Our max value by customer is A=30, B=15, C=40. Our min of those is 15. Note how we built a temporary table with three rows while calculating it. Aggr() is one way to build this temporary table. Our dimension is Customer, and our expression is max(Value). We could build this as a real chart, but instead we want to use it in an expression without doing so. The general format for aggr() is this:
So in our case:
We're trying to extract the minimum from that temporary table, that list of values, so we just enclose it in min():
The AGGR statement produces a virtual table, with one expression and grouped by one or more dimensions. The contents / result of this virtual table can then be used / aggregated by a further outer aggregation function(s).