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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ghdunn
Helper III
Helper III

conditional column: if [field] in (“a”,”b”,”c”) then x else y

I am adding a conditional column to a data table and find that If [field] = “a” then 1 else If [field] = “b” then 2 else..... etc etc ...works fine. However... I would like to use an ‘in’ condition like MS Access If [field] IN (“a”,”b”,”c”) then 3 else.... Looked extensively on web but nothing seems to deal with this. Thanks
1 ACCEPTED SOLUTION
LivioLanzo
Solution Sage
Solution Sage

Hello @ghdunn

 

you can use the List.Contains function: https://docs.microsoft.com/en-us/powerquery-m/list-contains

 

if List.Contains({"a","b","c"}, [field1]) then "it contains it" else "it does not contain it"

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

2 REPLIES 2
LivioLanzo
Solution Sage
Solution Sage

Hello @ghdunn

 

you can use the List.Contains function: https://docs.microsoft.com/en-us/powerquery-m/list-contains

 

if List.Contains({"a","b","c"}, [field1]) then "it contains it" else "it does not contain it"

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Thanks..I did look at ListContains but just didn't twig that the syntax would work like that...was so convinced that there would be some 'IN' condition hidden in 'M' 🙂  My bad.   Thanks for super quick response.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors