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
Anonymous
Not applicable

SQL IN operator equivalent in M code

Hi community,

Do you know if there is an expression in M code that mimics the IN operator in SQL? I am writting an IF ELSE statement to create a custom column, and would like to not repeat a column name multiple times using OR condition to list values. 

1 ACCEPTED SOLUTION
waltheed
Solution Supplier
Solution Supplier

Hi, 

 

I found the answer here.

 

So it should look something like this:

 

= if List.Contains({125,126,127,128},[Diagnosis_code]) then "Proc1" else if List.Contains({225,226,227,228},[Diagnosis_code]) then "Proc2" else null

 

 

Cheers, Edgar Walther
ITsmart BI and Analytics consultant

View solution in original post

1 REPLY 1
waltheed
Solution Supplier
Solution Supplier

Hi, 

 

I found the answer here.

 

So it should look something like this:

 

= if List.Contains({125,126,127,128},[Diagnosis_code]) then "Proc1" else if List.Contains({225,226,227,228},[Diagnosis_code]) then "Proc2" else null

 

 

Cheers, Edgar Walther
ITsmart BI and Analytics consultant

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.