Pragmatic Works Nerd News

Grouping Items Together in Power BI Visuals Using DAX Measures

Written by Nick Lee | May 03, 2026

In this tutorial, Nick Lee from Pragmatic Works demonstrates how to use DAX measures in Power BI to group items within visuals effectively. By leveraging powerful DAX functions such as ALL, ALLSELECTED, ALLEXCEPT, and REMOVEFILTERS, users can create dynamic calculations for more advanced and customized data visualizations. This guide is perfect for those seeking to enhance their DAX skills and improve their Power BI report functionality.

 

 

Why Group Items Using DAX?

Grouping items in Power BI visuals provides flexibility for calculating totals, percentages, and other metrics across different hierarchies and filters. This technique helps in creating visuals that display meaningful aggregations, such as totals by country, region, or custom groupings, while respecting user interactions like slicers and filters.

Step-by-Step Guide

1. Start with a Basic Total Sales Measure
  1. Create a new measure to calculate global total sales:
    Total Sales Global = SUM(Sales[SalesAmount])
  2. To ignore all filters applied to a table, use the ALL function:
    Total Sales Global = CALCULATE(SUM(Sales[SalesAmount]), ALL(SalesTerritory))

    This measure will display the global total sales value across all rows, regardless of applied filters.

2. Group Sales by Specific Columns

To calculate totals grouped by a higher level in the hierarchy (e.g., country), modify the filter context:

  1. Create a measure to group by country:
    Total Sales by Country = 
    CALCULATE(SUM(Sales[SalesAmount]), ALL(SalesTerritory[Region]))
  2. For grouping by multiple columns (e.g., country and region), use the ALL function with multiple columns:
    Total Sales by Group = 
    CALCULATE(SUM(Sales[SalesAmount]), ALL(SalesTerritory[Region], SalesTerritory[Country]))
3. Simplify Grouping with ALLEXCEPT

To future-proof your measure for changes in the visual, use ALLEXCEPT. This removes filters from all columns except the specified one:

Total Sales by Group = 
CALCULATE(SUM(Sales[SalesAmount]), ALLEXCEPT(Sales, SalesTerritory[Group]))
4. Incorporate Slicers with ALLSELECTED

Use ALLSELECTED to account for slicer selections while removing other filters:

Total Sales Adjusted = 
CALCULATE(SUM(Sales[SalesAmount]), ALLSELECTED(SalesTerritory[Group]))

This ensures the measure respects slicer interactions while still aggregating data as needed.

5. Understand REMOVEFILTERS

The REMOVEFILTERS function works similarly to ALL but is limited to removing filters within a CALCULATE function. For example:

Total Sales by Region = 
CALCULATE(SUM(Sales[SalesAmount]), REMOVEFILTERS(SalesTerritory[Region]))

Key Benefits

  • ✅ Create dynamic groupings for totals and percentages.
  • ✅ Maintain control over filter contexts for accurate calculations.
  • ✅ Simplify complex visual requirements with reusable DAX logic.

Conclusion

Grouping items in Power BI visuals using DAX measures offers flexibility and precision for creating advanced and intuitive reports. Whether you’re grouping by regions, countries, or custom hierarchies, these techniques will save time and enhance your report functionality. Try implementing these functions in your next Power BI project to unlock new analytical possibilities.

Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power BI and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.