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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How can I do a ' not in' in Power Query - New User

Hello,

 

   I am a new Power Query user. I a list of users in a list titled HomeOffice. I have a table of information for my SalesTeam. Some of our SalesTeam members are also in the HomeOffice list. I want to filter the SalesTeam table and remove the users in my HomeOffice list. Here is what I have so far:

 

let
Source = #"Merge of AD Users & Groups",
#"SA tbl" = Table.SelectRows(Source, each [Group Name] = "Sales Associates"),
#"HomeOffice" = #"Test Home Office",


in
#"SA tbl"

 

I am having trouble trying to filter the SA list[member name] with the values in the HomeOffice list. Basically I want all the data in the SA tbl except for SA tbl[member names] in the HomeOffice List. How do I do this?

 

Cheers,

 

Peter

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Indeed, it's the same concept.  If you have TableA, with columns Name, Column2, and Column3, and another table, TableB, with columns Names and Departments.  Any column in any table can be referred to as a list using the Table[ColumnName] syntax.  So:

 

Table.SelectRows(TableA, each not List.Contains(TableB[Names], [Name]))

 

TableB[Names] is the column from the other table that you are referring to as a list, and [Name] is the column in your current table that you are turning into a list to compare to the first list.

 

Very useful!--Nate  P.S. Please mark these as the answer.  Thanks!

View solution in original post

Anonymous
Not applicable

Hello,

 

   I change the #ASB Home Office" source back to a table. I went into the advanced editor and tried the following:

 

#"Filter2" = Table.SelectRows(#"Changed Type1", each not Table.Contains(#"ASB Home Office"[group.member.displayName],[group.member.displayName]))

 

and I get the error:

 

Expression.Error: We cannot convert a value of type List to type Table.

 

I seem to have a data-type mismatch in that line of code.

 

View solution in original post

7 REPLIES 7
edhans
Super User
Super User

Note that @Anonymous has the right of it, but I have one suggestion to make. Change your code to this:

#"Filter2" = 
    Table.SelectRows(
        #"Changed Type1", 
        each not List.Contains(
            List.Buffer(#"ASB Home Office"[group.member.displayName]),
            [group.member.displayName]
        )
    )

I added returns and spaces for readability, but the difference is the List.Buffer. I have seen massive performance improvements in List.Contains when used with a buffered vs raw list, especially if the list is from a relational database where query folding is still happening.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

True, @edhans, I do always buffer my lists!

Anonymous
Not applicable

Indeed, it's the same concept.  If you have TableA, with columns Name, Column2, and Column3, and another table, TableB, with columns Names and Departments.  Any column in any table can be referred to as a list using the Table[ColumnName] syntax.  So:

 

Table.SelectRows(TableA, each not List.Contains(TableB[Names], [Name]))

 

TableB[Names] is the column from the other table that you are referring to as a list, and [Name] is the column in your current table that you are turning into a list to compare to the first list.

 

Very useful!--Nate  P.S. Please mark these as the answer.  Thanks!

Anonymous
Not applicable

Hello,

 

   I change the #ASB Home Office" source back to a table. I went into the advanced editor and tried the following:

 

#"Filter2" = Table.SelectRows(#"Changed Type1", each not Table.Contains(#"ASB Home Office"[group.member.displayName],[group.member.displayName]))

 

and I get the error:

 

Expression.Error: We cannot convert a value of type List to type Table.

 

I seem to have a data-type mismatch in that line of code.

 

Anonymous
Not applicable

Change Table.Contains to List.Contains. 
--Nate

Anonymous
Not applicable

This works:

Table.SelectRows(#"SA tbl", each not List.Contains(NameOfYourHomeOfficeList, #"SA tbl"[member names]))

Anonymous
Not applicable

Hello,

 

   Thank you. that did work for me. Can you now show me how to do the same task, but with two tables instead of a list and a table?

 

Cheers,

 

Peter

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors