Forum Discussion

admin_xlsior's avatar
admin_xlsior
Post Prodigy
5 years ago
Solved

Filter one table based on other table still in Power Query

Hi guys,

 

In Advance Query (Power Query) can we filter 1 table based on other table ?

For example I have table Products which has column Active (Yes/No). I have filtered this during Transform data, to Yes only.

So at Transform data as well, I want the other Table which is TransactionTable to only have ProductId that in my table Products=Active.

 

I can do the filter in reports of course, by select Product Id "is not blank" because obviously after put relationship between this 2 tables, it will result blank Product Id in Transactions.

 

But I actually don;t want this, I want at time we in Transform or in Power Query, transactions table already filtered.

 

I'm using Direct Query, btw

 

Thanks,

 

 

 

 

  • Hi, admin_xlsior 

     

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

    Products:

     

    Transcation:

     

    You may add a new step for 'Transcation' table with the following m codes,

    = let
    lst = Table.SelectRows(Products,each [IsActive]="Yes")[ProductID],
    result = Table.SelectRows(#"Changed Type",each List.Contains(lst,[ProductID]))
    in
    result

     

     

    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.

3 Replies

  • v-alq-msft's avatar
    v-alq-msft
    Community Support

    Hi, admin_xlsior 

     

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

    Products:

     

    Transcation:

     

    You may add a new step for 'Transcation' table with the following m codes,

    = let
    lst = Table.SelectRows(Products,each [IsActive]="Yes")[ProductID],
    result = Table.SelectRows(#"Changed Type",each List.Contains(lst,[ProductID]))
    in
    result

     

     

    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.

    • admin_xlsior's avatar
      admin_xlsior
      Post Prodigy

      Awesome!

       

      Just what I need, Thank you very much, Allan. ğŸ˜‡

  • MattAllington's avatar
    MattAllington
    Community Champion

    You will need to do a combine tables with an inner join between the product table and the transaction table. I don't know if you can do this with direct query - I assume you can.