Daily DAX : Day 435 ROLLUPGROUP
Power BI DAX Function: ROLLUPGROUP
Overview
The ROLLUPGROUP function in DAX is used within SUMMARIZE or SUMMARIZECOLUMNS expressions to control how rollup (subtotal and grand total) rows are generated.
It groups multiple columns together, treating them as a single unit in the rollup hierarchy. This allows you to create combined subtotals instead of separate partial subtotals for each column.
Note: ROLLUPGROUP does not return a value itself; it modifies the behavior of grouping and rollup operations.
Syntax
ROLLUPGROUP ([, [, … ] ] )
It is typically used inside a ROLLUP or directly in the grouping parameters of SUMMARIZE.
Use Cases
- Creating grouped subtotals: When you have multiple grouping columns (e.g., Year and Education Level) and want a single subtotal that combines them, rather than separate subtotals for each.
- Avoiding partial subtotals: In complex hierarchies, using ROLLUPGROUP inside ROLLUP prevents unwanted intermediate subtotal rows.
- Generating summary tables with hierarchies: Useful for reports needing subtotals at specific levels, like total by region+product as one group.
- Advanced aggregation: In combination with
ISSUBTOTALto flag subtotal rows for custom formatting or calculations in visuals.
Simple Example
Without ROLLUPGROUP, separate ROLLUP on Year and Category might produce individual subtotals for Year and for Category.
With ROLLUPGROUP:
SUMMARIZE(
Sales,
ROLLUP( ROLLUPGROUP( 'Date'[Year], Product[Category] ) ),
"Total Sales", SUM(Sales[Amount])
)
This treats Year and Category as one group, producing a single combined subtotal row (and grand total) instead of separate ones.
Key Benefits
- Reduces unnecessary subtotal rows in summary tables.
- Provides finer control over hierarchical aggregations.
- Improves performance and clarity in complex DAX table expressions.
Comments
Post a Comment