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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors