Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Filter a table based on other table with two columns

Hello, 

Im trying to do this calculation on power query,

I have two tables (Table 1 and Table 2), and I want to filter the information in Table 2 from Table 1 and I am looking for two things:
1. If the records exist within the Table 1 table, leave me those records, delete the other records that correspond to the same country (USA) and leave me all other records of the other countries.

2. If the records exist within Table 1, I remove those records and leave all other records of the same country (USA) and other records of the other countries.

 

I hope someone could help me, with this.

 

Table 1Table 1Table 2Table 2

14.JPG15.JPG

 

Thanks for the help!

 

Greetings

Mónica

1 ACCEPTED SOLUTION

2 is easiest:

Start with Table2 and merge it with JoinKind.LeftAnti with Table1. This will keep all rows from Table2 that are NOT contained in Table1.

 

for the first case I'd group both tables on Country and then do a LeftAnti Merge to keep just those countries who are not included in Table 1 and then a JoinKind.Inner to grab the countries where there is a match. Then a RightAnti on these results to keep only those who were included. Then append both tables.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

This seems like a problem for @ImkeF. Probably create a column that grabs your other table and this will appear as "Table" in this new column and then do something fancy with it.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

2 is easiest:

Start with Table2 and merge it with JoinKind.LeftAnti with Table1. This will keep all rows from Table2 that are NOT contained in Table1.

 

for the first case I'd group both tables on Country and then do a LeftAnti Merge to keep just those countries who are not included in Table 1 and then a JoinKind.Inner to grab the countries where there is a match. Then a RightAnti on these results to keep only those who were included. Then append both tables.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

@ImkeF Thanks a lot for your help,  Its works perfect!!

 

@Greg_Deckler Thanks to you too.

 

Greetings

Mónica

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.