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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dino19547
Regular Visitor

Subtotal not Matching Detailed Items

 Hi PBI community,

 

I am having issues with subtotals not adding up to total items in a category in a matrix.

 

My goal is to get the quantities sold for a Product.

 

For this I need to multiply:

  • Qantity (Cartons) column in Sales Table x
  • Qty per Carton column in Product Table

This is my measure formula:

Qty Sold = SUM(Sales[Quantity]) * SUM(Products[Unit])

 

And this is an example of my two tables above:

Product Table  
   
SKUCheese TypeQty in Carton
Brie01Brie10
Brie02Brie10
Brie03Brie10
Camembert01Camembert5

 

Sales Table 
  
SKUQty Sold
Brie011
Brie021
Brie031
Camembert013

 

As evident they are joined by the SKU column which has unique values.

 

Now, when filtering by "Cheese Type" I am expecting to obtain

 

  • 30 for Brie (10 x 1) + (10 x 1) + (10 x 1) and
  • 15 for Camembert (5 x 3)

Since Camembert is a unique value at both SKU and Cheese Type level - there are no issues returning the correct amount

 

However for Brie subtotal - instead of 30, I obtain 90 - which I believe happens because the engine is multiplying by 3 when finding 3 types of Brie cheese products.

 

What's the most effective way to deal with these type of issues 

1 ACCEPTED SOLUTION
Tanushree_Kapse
Impactful Individual
Impactful Individual

Hi @dino19547 ,

 

Try using following measure:

 

Tanushree_Kapse_0-1632742115937.png

 

 

Qty Sold2 = SUMX(VALUES('Table (3)'[SKU]),(CALCULATE(SUM('Table (3)'[Qty Sold])* SUM('Table (2)'[Quantity in Carton]))))
 
 
Mark this as a solution, if I answered your question. Kudos are always appreciated.
Thanks

 

View solution in original post

4 REPLIES 4
dino19547
Regular Visitor

Hi Tanushree, may I ask - why does your solution work with Values(Table[SKU] and not with Values(Table[Cheese Type] under this filter context? Sorry this is a burning question I have!

dino19547
Regular Visitor

Thank you @Tanushree_Kapse, it worked!

Great!
Please Mark this as a solution, if I answered your question. Kudos are always appreciated.
Thanks
Tanushree_Kapse
Impactful Individual
Impactful Individual

Hi @dino19547 ,

 

Try using following measure:

 

Tanushree_Kapse_0-1632742115937.png

 

 

Qty Sold2 = SUMX(VALUES('Table (3)'[SKU]),(CALCULATE(SUM('Table (3)'[Qty Sold])* SUM('Table (2)'[Quantity in Carton]))))
 
 
Mark this as a solution, if I answered your question. Kudos are always appreciated.
Thanks

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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