Grouping Items Together in Power BI Visuals Using DAX Measures
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
- Create a new measure to calculate global total sales:
Total Sales Global = SUM(Sales[SalesAmount]) - To ignore all filters applied to a table, use the
ALLfunction: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:
- Create a measure to group by country:
Total Sales by Country = CALCULATE(SUM(Sales[SalesAmount]), ALL(SalesTerritory[Region])) - For grouping by multiple columns (e.g., country and region), use the
ALLfunction 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.
Sign-up now and get instant access
ABOUT THE AUTHOR
Nick has been a dedicated trainer and consultant since 2018, leveraging his extensive experience working with major companies, including Fortune 200 corporations, professional sports organizations, government entities, and leading firms in the finance and healthcare sectors. With a specialized focus on Power BI and data engineering, Nick has consistently demonstrated his ability to drive data-driven decision-making and optimize business processes. His commitment to excellence and his in-depth technical expertise have made him a trusted advisor and sought-after expert in the industry.
Free Community Plan
On-demand learning
Most Recent
private training

Leave a comment