Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Merge two tables using Power Query with multiple conditions

Hi Team, I have 2 tables as below (Table1 and Table2). I have to join these 2 tables with multiple joining criteria: Join on Transaction_ID from both the tables and Also, join on Table1.Transacti...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi

     

    You can do this in two steps:

     

    First merge the two tables by transaction ID, it will create a new column that will have a table in each row.

     

     

    Then create a new custom column to get only the value you want from those tables, filtering your date field:

     

    = Table.AddColumn(#"Changed Type", "Amount", each let mydate = [Transaction_dt] in
    Table.SelectRows([Table 2],
    each [Sale_From_Dt] < mydate and
    [Sale_To_Dt] >= mydate))

     

    After this you need to expand your new custom column by the fields you want

     

     

    Hope it helps

    Kind regards,
    José
    Please mark this answer as the solution if it resolves your issue.
    Appreciate your kudos! 🙂