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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Krutigawale33
Responsive Resident
Responsive Resident

Hello @bo_afk ,

 

You better create column instead of measure and try,

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

 

Hi @Krutigawale33, 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]))

 

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.