cancel
Showing results for 
Search instead for 
Did you mean: 
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

Accepted Solutions
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
Power BI User Group Netherlands

View solution in original post

1 REPLY 1
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
Power BI User Group Netherlands

View solution in original post

Helpful resources

Announcements
November Update

Check it Out!

Click here to read more about the November 2020 Updates!

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform October Community Highlights

Check out the top community contributors across all of the communities

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors