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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
bo_afk
Post Patron
Post Patron

Sum values by category in table

I've created a measure to sum my values grouped by 2 categories using the SUM and ALLEXCEPT functions, however it's not calculating the numbers as expected.

Table

Category2Category1ProductIDSales
1BagABC123100
2BagABC123200
1BagXYZ456300
2BagXYZ456400
1ShoesDEF567800
2ShoesDEF567700

 

Measure = CALCULATE(SUM(Value)),ALLEXCEPT(Table,[Category1],[Category2]))

 

When I put the values into the table and include category 2, the correct value is calculated. However, when I remove category2 from the table, the figures change. I would've expected the grouped sum up to category2 to remain but it doesn't.

How can amend my measure to display the expected outcome below?

Current outcome (incorrect)

Grouped values.JPG

Exected outcome

Category1ProductIDSalesMeasure
1ABC123100400
2ABC123200600
1XYZ456300400
2XYZ456400600
1DEF567800800
2DEF567700700
5 REPLIES 5
Anonymous
Not applicable

Hi @bo_afk,

Can you please share some dummy data with a similar data structure and expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hello @bo_afk ,

 

You better create column instead of measure and try,

Column = CALCULATE(SUM(Table[Sales]),ALLEXCEPT(Table,Sheet15[Category1],Table[Category2]))

 

Hi @Anonymous, thanks for the suggestion. This does seem to work however this doesn't dynamically calculate if I apply other filters in the report. Am I really unable to create this as a measure so that the figure changes with filters?

amitchandak
Super User
Super User

@bo_afk , Try like

 

Measure = CALCULATE(SUM('Table (2)'[Sales]), REMOVEFILTERS('Table (2)'[Category1],'Table (2)'[Category2]))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak, thanks for your suggestion. Unfortunately this hasnt completely worked. It sums it up by productID but not by category 2.

Grouped values 2.JPG

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors