Forum Discussion

Joshva's avatar
Joshva
New Member
2 years ago
Solved

How to compare/calculate between two columns from different tables with missing values?

My goal is to compare two columns that are supposed to be the same. Due to some missing/differing data, this is harder to work with. The structure is simple: ID, amount. I want a measure that express...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Joshva ,

     

    bjertf , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement. Please check if there is anything that can be improved. Here is my solution:

     

    1.Create simple data:

     

     

    2.In Power Query Editor, append the two tables into a single table:

     

     

    The relationship is as follows:

     

     

    3.Create a new measure:

     

    Measure = 
    VAR _sum1 = CALCULATE(SUM(A[Amount]),FILTER(ALL(A),'A'[ID] = MAX('Append1'[ID])))
    VAR _sum2 = CALCULATE(SUM(B[Amount]),FILTER(ALL(B),'B'[ID] = MAX('Append1'[ID])))
    RETURN
    _sum1 - _sum2
    

     

    4.The final result is as follows:

     

     

    Best Regards,
    Zhu
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!