Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to make expression if more than 1 aggregate function?

How to make expression if more than 1 aggregate function.

This code like : My Dimension is Branch, Year, Month, and ITEM_CODE.

Branch     Year     if(aggr(count(DISTINCT ITEM_CODE), Year, Month) >= 5, 1, 0))

A               2001     3500

B               2002     4600

A               2003     5505

C               2004     6003

B               2005     3550

May be someone can help me more explain about aggr function?

Why in Straigt Table, i must show field Year and Month to get the result value?

1 Reply
hic
Former Employee
Former Employee

The Aggr function will create an array of values. The first parameter, which must be an aggregation function, e.g. Sum or Count, defines the values in the array and the other parameters define the grouping fields (like SQL GROUP BY).

The aggr function can only be used in the UI objects (cannot be used in the script).

In your case you must have Year and Month as dimensions in the chart - otherwise the Aggr will return several values, which cannot be used unless you put another aggregation function outside the Aggr function, e.g.

Sum(Aggr(Count(...), Month, Year))

/HIC