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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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