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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
Super User
Super User

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
Super User
Super User

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
Super User
Super User

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors