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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
qasimawan
Frequent Visitor

Check if a value exists in another table

Hello Community!

 

I am relatively new M Langauge and I want to know how to check if the string exists in another column. I have used an Excel formula such as: isNumberMatch

 

I will elaborate on my question further to provide some context.

 

I have two queries:

 

Query 1 contains my source data which has every detail.

Query 2 is another table that contains data.

 

I have done a string concatenation in both queries, meaning, i have joined, FirstName, LastName and EmailAddress.

 

In query 2, I want to create a custom column which checks if the concatenated column in Query 2 matches the concatenation in Query 1. 

 

I have tried to do this but I don't know how to reference a column in another query:

if Table.SelectColumns(#"NHSP Data Edit","Concat") = Table.SelectColumns(#"Daily SiP - Edit","Concat") then "true" else "false"

 

Thanks for your help!

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @qasimawan ,
sorry, yes, the code has to be adjusted:
if List.Contains(#"query1"[Concat], [Concat]) then "true" else "false"

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
ImkeF
Community Champion
Community Champion

Hi @qasimawan ,
sorry, yes, the code has to be adjusted:
if List.Contains(#"query1"[Concat], [Concat]) then "true" else "false"

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

qasimawan
Frequent Visitor

Hi Imkef, 

 

Many thanks for your reply! 

 

Unfortunately, I have ran into this error which I can't eliminate. I have added a change type step and manually changed the data types but the error hasn't gone away. 

 

Here is the error message: Expression.Error: We cannot convert a value of type Table to type List.
Details:
Value=[Table]
Type=[Type]

ImkeF
Community Champion
Community Champion

Hi @qasimawan ,

if my understanding is correct, you want to check if a certain value in each row of a table (query2) is contained anywhere in the whole column of table from query1.
If so, you'd add a column in query2 like so:

if List.Contains( Table.SelectColumns(#"query1","Concat"), [Concat]) then "true" else "false"

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.