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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
KayCent
Frequent Visitor

How to sum quantity sold using data from two columns

 

Hi Everyone, 

I need help on solving my current issue. 

I have a sales table that has 3 columns : Item No, Gen No and Qty.

 

I have a slicer for Item No. If i select a No, i would like to check the "No" selected on the "No" Column and also check if the number is present in the "Gen No" Column and return a sum of quantity where this is fulfilled. 

Below is an illustration of my table and the exprected result 

 

NoGen NoQty
104
206
328
413
535
   

 

Expected Result 

 

NoQty
17
214
313
43
55

 

Thanks 

 

1 ACCEPTED SOLUTION

@KayCent try this measure, In expression, change table and column name as per your data model.

 

Sum Qty = 
VAR __no = MAX ( 'Table (2)'[No] )
VAR __qty = SUM ( 'Table (2)'[Qty] )
VAR __genNoQty = CALCULATE( SUM ( 'Table (2)'[Qty] ), ALL ( 'Table (2)'[No] ), 'Table (2)'[Gen No] = __no )
RETURN __qty + __genNoQty

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

8 REPLIES 8
parry2k
Super User
Super User

@KayCent not sure it is clear how you are getting the query in output table. can you clarify



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks . 

 

It is a sum of the Qty value where the No is present in the Gen No Column

NoQty
14+3 = 7
26+8=14
38+5=13
43
55
  

@KayCent I see, in original post, you mentioned just sum where gen no value match with no but you are adding the value of  no row + value of gen no which matches with no, correcT?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Correct. 

@KayCent try this measure, In expression, change table and column name as per your data model.

 

Sum Qty = 
VAR __no = MAX ( 'Table (2)'[No] )
VAR __qty = SUM ( 'Table (2)'[Qty] )
VAR __genNoQty = CALCULATE( SUM ( 'Table (2)'[Qty] ), ALL ( 'Table (2)'[No] ), 'Table (2)'[Gen No] = __no )
RETURN __qty + __genNoQty

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Many Thanks. still did not get the desired result. 

 

It seems it does not include this 

VAR __genNoQty = CALCULATE( SUM ( 'Table (2)'[Qty] ), ALL ( 'Table (2)'[No] ), 'Table (2)'[Gen No] = __no )
R

It shows no values for the above Variable.  

@KayCent here is the output based on your dataset, not sure if there is other tables/filters have an impact

 

image.png



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks alot @parry2k  for your time and patience.

 

It worked!!! 

 

As you said, there was another filter impacting it. 

 

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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