Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Percentage Subtotals on Matrix Incorrect

I'm building a capacity planner and I cannot for the life of me get the subtotal percentages to work.  In the matrix below, the main values are correct, but the subtotals for rows and columns and the grand total are not.  There are 2 tables, the first contains a single row for each employee for each month per project and role.  The table below has the hours summed by employee and month.  The percentages shows how much capacity is used.  PTO hours are removed and then the rest of the hours are divded by the total hours available for the month minus the PTO hours.  The total hours available are calculated from a date dimension by multiplying working days (weekdays minus holidays) times 8.

 

Calculations:

TotalWorkingHours = SUMX(FILTER('Capacity Planner','Capacity Planner'[Role]<>"Hours NOT Available"),'Capacity Planner'[Hours])

HoursAvailable = MAX(DateTable[WorkingHoursAvailable]) 
     - SUMX(FILTER('Capacity Planner','Capacity Planner'[Role]="Hours NOT Available"),'Capacity Planner'[Hours])

WorkingHours%Used = DIVIDE([TotalWorkingHours],[HoursAvailable])

mattclau_0-1629822620528.png

 

I tried various ways to build a seperate measure for the subtotals using all or allexcept and found no luck.  Any help is appreciated.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Anonymous This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks! That pointed me in the right direction.  I needed 2 HASONEFILTER functions to get both the columns and row subtotals correct.  

HoursAvailable = IF(HASONEFILTER('Capacity Planner'[ResourceName]),IF(HASONEFILTER('Capacity Planner'[EndOfMonth]),
                    MAX(DateTable[WorkingHoursAvailable]) - [HoursFiltered],
                    DISTINCTCOUNT('Capacity Planner'[EndOfMonth]) * MAX(DateTable[WorkingHoursAvailable]) - [HoursFiltered]),
                    DISTINCTCOUNT('Capacity Planner'[ResourceName]) * MAX(DateTable[WorkingHoursAvailable]) - [HoursFiltered])

Hoursfiltered is a new measure that contains the sumx from above to help with readability.  Any idea how I would get the grand total corect?   I probably just need to reorder the ifs, but my logic brain isn't getting it at the moment:

mattclau_0-1629827413864.png

 

Anonymous
Not applicable

I needed to multiply the two distinct count columns together on both hasonefilters to get the correct values.  It took way too long to get to that logic in my brain, but it makes sense because when there's subtotals, it's multiplying by 1 and for the grand total, it's the total number of cells in the matrix.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.