Newer Version Available
grouping()
Returns 1 if null dimension values are due to higher-level aggregates (which
usually means the row is a subtotal or grand total), otherwise returns 0.
The grouping() function is most useful when paired with the rollup modifier on the group statement. Invoking grouping() lets work with subtotaled data.
Example - Label Subtotaled Data
Suppose that you have a dataset of opportunity information with amounts totaled
by lead source and type. Calculate totals with rollup. Then use grouping() with a case
statement to check whether a row is a total and if it is then label it as
"all"
values.
