ROLLUPGROUP in DAX: Grouping Columns Without Intermediate Subtotals
In this article, we will learn how to use ROLLUPGROUP together with ROLLUP inside SUMMARIZE to create grouped summary results with a total row, without generating intermediate subtotal rows.
📥 Practice Data:
Download Practice Data Free
🎥 Prefer learning through video?
DAX YouTube Playlist
What Is ROLLUPGROUP in DAX?
ROLLUPGROUP is used inside ROLLUP to treat multiple grouping columns as a single group when generating subtotal and total rows.
In this query, Category and Subcategory are grouped together. The result contains the detailed Category–Subcategory combinations and an overall total, while avoiding a separate subtotal row for each Category.
ROLLUPGROUP is useful when you want several columns to participate together in the rollup hierarchy rather than generating intermediate subtotal levels between them.
Query
// ROLLUP GROUP
EVALUATE
SUMMARIZE(
Sales,
ROLLUP(
ROLLUPGROUP(
'Product'[Category], 'Product'[Subcategory]
)
),
"Total Sales", SUM(Sales[Sales Amount])
)
Step-by-step Explanation
Step 1: EVALUATE
EVALUATE is used to return the result of the DAX table expression.
In this query, the table expression is created using SUMMARIZE.
EVALUATE
SUMMARIZE(
...
)
Step 2: SUMMARIZE
SUMMARIZE creates a summary table by grouping the data according to the columns supplied in the query.
Here, the source table is Sales, and the grouping definition is provided by ROLLUP.
SUMMARIZE(
Sales,
ROLLUP(
...
),
"Total Sales", SUM(Sales[Sales Amount])
)
Step 3: ROLLUP
ROLLUP extends the grouping operation so that DAX can generate higher-level total rows in addition to the detailed grouped rows.
The important part of this query is that the grouping columns are wrapped inside ROLLUPGROUP.
ROLLUP(
ROLLUPGROUP(
'Product'[Category],
'Product'[Subcategory]
)
)
Step 4: ROLLUPGROUP
ROLLUPGROUP groups Category and Subcategory together as one rollup group.
This is important because, without ROLLUPGROUP, the rollup hierarchy can generate intermediate subtotal levels. By placing both columns inside ROLLUPGROUP, they are treated together for the rollup operation.
Here, Category and Subcategory are treated as one rollup group. Therefore, the query does not create a separate Category-level subtotal between the detailed rows and the grand total.
Step 5: Category and Subcategory
The two columns used for grouping are:
- ‘Product'[Category] — the product category.
- ‘Product'[Subcategory] — the product subcategory.
Together, they define the detailed grouping level of the result.
Step 6: Creating the Total Sales Column
The final argument of SUMMARIZE creates a calculated summary column named Total Sales.
"Total Sales", SUM(Sales[Sales Amount])
For every generated group, DAX calculates the sum of Sales[Sales Amount].
Understanding the Result
The result will contain the detailed combinations of Category and Subcategory, followed by an overall total row.
| Category | Subcategory | Total Sales |
|---|---|---|
| Accessories | Bikes Stands | Detailed Sales |
| Accessories | Locks | Detailed Sales |
| Bikes | Mountain Bikes | Detailed Sales |
| Bikes | Road Bikes | Detailed Sales |
| Blank | Blank | Grand Total |
The values shown above are illustrative. Your actual result depends on the data available in the Sales and Product tables.
Why Use ROLLUPGROUP?
Consider the hierarchy:
Category
└── Subcategory
A normal rollup can generate multiple levels of totals as it moves through the hierarchy. When ROLLUPGROUP wraps both columns, DAX treats the columns as a single rollup group.
This is useful when your requirement is to show:
- Category and Subcategory detail
- One overall grand total
- No intermediate Category subtotal rows
ROLLUP vs ROLLUPGROUP
| Function | Purpose |
|---|---|
| ROLLUP | Generates rollup subtotal and total rows for grouping columns. |
| ROLLUPGROUP | Groups multiple columns together so they are treated as one rollup group. |
Important Concept
The key difference is not that ROLLUPGROUP creates another type of total. Instead, it changes how the columns inside the rollup are treated during subtotal generation.
Use ROLLUPGROUP when multiple grouping columns should be treated as one unit within a ROLLUP operation.
📝 Practice Exercise
Try modifying the query to group the Sales table by Product Category and Product Subcategory using ROLLUP and ROLLUPGROUP.
Then compare the result with a query where the two columns are supplied directly to ROLLUP.
Observe how the subtotal rows differ between the two queries.
Conclusion
In this article, we learned how ROLLUPGROUP works with ROLLUP inside SUMMARIZE.
- SUMMARIZE creates the grouped summary table.
- ROLLUP adds rollup total levels to the grouping.
- ROLLUPGROUP treats multiple grouping columns as one rollup group.
- Category and Subcategory can therefore be rolled up together.
- This approach is useful when you want detailed combinations and a grand total without an intermediate Category subtotal.
Understanding ROLLUP and ROLLUPGROUP is important when building advanced DAX queries for hierarchical summaries and reporting scenarios.
📥 Practice Data:
Download Practice Data Free
🎥 Prefer learning through video?
DAX YouTube Playlist