Forum Discussion

ptmuldoon's avatar
ptmuldoon
Resolver I
5 years ago
Solved

Loading a Table based based on another table

Is there a way to load a table into Excel only the rows of data that match in another table? For example.  I have two tables in PowerQuery.  One called "Data" that contains accounting data for XX ye...
  • JamesHowell's avatar
    5 years ago

    Hi ptmuldoon ,

     

    Using a Right Outer Join might be the approach you are looking for to load a table with just those specific rows.

     

    To achieve this I'd recommend setting up a staging table (connection only) of your ItemsList table in PowerQuery filtered to OnDashboard = Yes. Once you have that you can use the Merge Queries as New to merge the Data table and the stage_ItemsList Table using a RightOuter join. The right outer join will effectively filter your Data table to the records that are matched in the stage_ItemsList table.

    Here's s snip of how I set that up. 

     

    The result of which is:

     

    YearItemNo.Amount
    2020110
    2019120
    2019320

     

     

     

     

     

    If you need a more detailed explanation see Miguel Escobar's post on this. It is fantastic: Merge Operations in Power BI / Power Query – Part 2: Right Outer Join — Powered Solutions

     

    There are a few other ways to approach this, but this one might be the simplest. I hope this helps and good luck!

  • v-alq-msft's avatar
    5 years ago

    Hi, ptmuldoon 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Table1:

     

    Table2:

     

    You may add a new step with the following m codes in 'Table1'.

    = let 
      l = Table.SelectRows(Table2,each [OnDashboard]="Yes")[ItemNumber],
      res = Table.SelectRows(#"Changed Type",each List.Contains(l,[ItemNumber]))
      in 
      res

     

    Result:

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.