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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Measure to calculate sum of (SKU * Unit Cost) on a Product Category Level?

Hi all, I am trying to create a measure that lets me calculate the total cost properly on the product category level.

 

I have managed to calculate the total cost for SKU level, but the subtotal/grandtotal isn't correct. The DAX formula I used is:

SUMX( SalesTable, SalesTable[Quantity] * RELATED(Product[Unit Cost]))

 

I think for the category level, the measure should look something like CALCULATE(SUM(SalesTable[Quantity]), FILTER(...)), but I don't know how to build it. Do I write "FILTER( SalesTable[SKU]=VALUES(Product[SKU])"? 


How do I use the FILTER function correctly (if that is indeed the correct function to use)?

1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

Your first measure should work for category too. Have you tested it?



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

8 REPLIES 8
MattAllington
Community Champion
Community Champion

Your first measure should work for category too. Have you tested it?



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

Thank you! I realised I made a silly error in the fields used.

Anonymous
Not applicable

Yes I've tested it, but for some reason there's a difference in the subtotal (and grand total) and when I highlight the individual entries.

 

Also, isn't SUMX calculation intensive?

 

Untitled picture.png

@Anonymous,

 

Share us a simplified model, then we could have a test.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi all, I am trying to create a measure that lets me calculate the total cost properly on the product category level.

 

I have managed to calculate the total cost for SKU level, but the subtotal/grandtotal isn't correct. The DAX formula I used is:

SUMX( SalesTable, SalesTable[Quantity] * RELATED(Product[Unit Cost]))

 

I think for the category level, the measure should look something like CALCULATE(SUM(SalesTable[Quantity]), FILTER(...)), but I don't know how to build it. Do I write "FILTER( SalesTable[SKU]=VALUES(Product[SKU])"? 


How do I use the FILTER function correctly (if that is indeed the correct function to use)?

Anonymous
Not applicable

Hi all, I am trying to create a measure that lets me calculate the total cost properly on the product category level.

 

I have managed to calculate the total cost for SKU level, but the subtotal/grandtotal isn't correct. The DAX formula I used is:

SUMX( SalesTable, SalesTable[Quantity] * RELATED(Product[Unit Cost]))

 

I think for the category level, the measure should look something like CALCULATE(SUM(SalesTable[Quantity]), FILTER(...)), but I don't know how to build it. Do I write "FILTER( SalesTable[SKU]=VALUES(Product[SKU])"? 


How do I use the FILTER function correctly (if that is indeed the correct function to use)?

Anonymous
Not applicable

Can someone tell me if the info I provided is incomplete? 

Hi John,

 

Are you able to provide the pbix file, your first query looks good and should work throughout but would need to see the model to get a better understanding of the problem.

 

Thanks,



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors