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

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors