ROLLUP
In SUMMARIZE, adds subtotal rows for the columns named.
Group: Table manipulation. Compatible with DAX.
Syntax
ROLLUP ( <groupBy_columnName> [, <groupBy_columnName>] … )
| Parameter | Type | Description |
|---|---|---|
groupBy_columnName | Column repeatable | A grouping column of the SUMMARIZE that should get subtotals; a ROLLUPGROUP counts as one. |
Returns
No value. It marks the grouping columns that SUMMARIZE adds subtotal rows for.
Remarks
- Put it among SUMMARIZE's grouping columns. With one column it adds a grand total row; with several the totals nest from the last column outwards: products within a category, then each category, then the grand total.
- On a subtotal row the rolled-up columns are blank, and the expressions are evaluated over the whole group.
ISSUBTOTALtells those rows apart. - Grouping columns before the ROLLUP get no totals of their own: a ROLLUP of the product after the category gives a total per category but no grand total.
- It works only among SUMMARIZE's grouping columns. In
SUMMARIZECOLUMNS, useROLLUPADDISSUBTOTAL. - The rows come in no set order: sort them with ORDER BY, an ISSUBTOTAL column first, to put the totals last.
Examples
A grand total
EVALUATE
SUMMARIZE (
Sales,
ROLLUP ( Products[Category] ),
"Liters", SUM ( Sales[Liters] ),
"Total row", ISSUBTOTAL ( Products[Category] )
)
ORDER BY [Total row], Products[Category]
| Products[Category] | Liters | Total row |
|---|---|---|
| Beer | 1505389 | FALSE |
| Cider | 301074 | FALSE |
| (blank) | 1806463 | TRUE |
A total per category, no grand total
EVALUATE
SUMMARIZE (
Sales,
Products[Category],
ROLLUP ( Products[Product] ),
"Liters", SUM ( Sales[Liters] ),
"Category total", ISSUBTOTAL ( Products[Product] )
)
ORDER BY Products[Category], [Category total], Products[Product]
| Products[Category] | Products[Product] | Liters | Category total |
|---|---|---|---|
| Beer | IPA | 331884 | FALSE |
| Beer | Lettøl | 169179 | FALSE |
| Beer | Pils | 1004326 | FALSE |
| Beer | (blank) | 1505389 | TRUE |
| Cider | Cider | 301074 | FALSE |
| Cider | (blank) | 301074 | TRUE |
Two nested levels
EVALUATE
SUMMARIZE (
Sales,
ROLLUP ( Products[Category], Products[Product] ),
"Liters", SUM ( Sales[Liters] ),
"Category total", ISSUBTOTAL ( Products[Product] ),
"Grand total", ISSUBTOTAL ( Products[Category] )
)
ORDER BY [Grand total], Products[Category], [Category total], Products[Product]
| Products[Category] | Products[Product] | Liters | Category total | Grand total |
|---|---|---|---|---|
| Beer | IPA | 331884 | FALSE | FALSE |
| Beer | Lettøl | 169179 | FALSE | FALSE |
| Beer | Pils | 1004326 | FALSE | FALSE |
| Beer | (blank) | 1505389 | TRUE | FALSE |
| Cider | Cider | 301074 | FALSE | FALSE |
| Cider | (blank) | 301074 | TRUE | FALSE |
| (blank) | (blank) | 1806463 | TRUE | TRUE |