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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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