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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Jgrohows
Frequent Visitor

Custom Column - Nested IF / AND Formula

Hello,

 

I am working on a  project where I need to provide a numerical score from 1-5 based on two criteria: (1) facility type (cateogried as Text) and (2) Cycle time (measured in days and categorized as Whole Number). I am new to PowerBi and still trying to learn the different syntax compared to Excel, but this is how i would write the formula using Excel:

 

=IF(AND(FacilityType="Hospital",CycleTime<10),5

   IF(AND(FacilityType="College",CycleTime<15,5

   IF(AND(FacilityType="Other",CycleTime<20,5

   IF(AND(FacilityType="Hospital",CycleTime<15),4

   IF(AND(FacilityType="College",CycleTime<20,4

   IF(AND(FacilityType="Other",CycleTime<25,4 

 

....... So on and so forth.

 

There are 5 different facility types and 6 different scores i want to provide. However I cant seem to make this work in Power Query as a new Cusotm Column. Does anyone have any suggestions on how to do this? 

 

Thank you!

Joe

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @Jgrohows ,

 

It appears you are trying to use the DAX code language in Power Query, although Power Query uses a language called "M".

 

In your example, the code would look something similar to this:

if [FacilityType] ="Hospital" and [CycleTime] < 10 then 5 

else if [FacilityType] ="College" and [CycleTime] < 15 then 5 

else if ...

 

Note, M is case sensitive: "and" and "else" and "if" need to be written in small letters.

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
Jgrohows
Frequent Visitor

Thank you  very much!  I appreciate your quick and very helpful response. 

tackytechtom
Super User
Super User

Hi @Jgrohows ,

 

It appears you are trying to use the DAX code language in Power Query, although Power Query uses a language called "M".

 

In your example, the code would look something similar to this:

if [FacilityType] ="Hospital" and [CycleTime] < 10 then 5 

else if [FacilityType] ="College" and [CycleTime] < 15 then 5 

else if ...

 

Note, M is case sensitive: "and" and "else" and "if" need to be written in small letters.

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

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.