Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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 

 

  • parry2k's avatar
    parry2k
    6 years ago

    Anonymous 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

     

8 Replies

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      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
        
      • parry2k's avatar
        parry2k
        Super User

        Anonymous 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?