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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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.

View solution in original post

8 REPLIES 8

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.
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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