The ROLLUPGROUP function identifies a set of columns specified in the SUMMARIZE function for which that function should calculate subtotals.
ROLLUPGROUP(
groupBy_columnName
[, groupBy_columnName...]
)
- groupBy_columnName: Field for which the SUMMARIZE function should calculate subtotals.
The ROLLUPGROUP function does not return any value.
The ROLLUPGROUP function is only used as an argument to SUMMARIZE or ADDMISSINGITEMS.
If we start from a data model with tables for sales (Sales), product categories (Category) and geographical locations (Geography), we could create a table calculated with the aggregated values of the sales figure and number of units sold by country and category with the following code:
Tabla = SUMMARIZE(
Sales,
Geography[Country],
Category[Category],
"Sales", SUM(Sales[Amount]),
"Units", SUM(Sales[Units])
)
Now, if we modify the code as follows:
Tabla = SUMMARIZE(
Sales,
Geography[Country],
ROLLUPGROUP(Category[Category]),
"Sales", SUM(Sales[Amount]),
"Units", SUM(Sales[Units])
)
...we see how the SUMMARIZE function adds the subtotals for each of the countries grouping all the categories: