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
Anonymous
Not applicable

Nested IF loop Formula not working properly

Hi Everyone,
I am facing a problem with defining a formula for a column.
Can anyone help me why am I facing this problem? I have defined a new column called Accuracy with the following logic:
FORMULA:
Estimate_Accuracy = IF(((Event[Est] = 1||2||3) && (Event[Time] = "On Time") && (Event[Quality] = "GOOD")),"Accurate Estimate",IF(Event[Est]=0,"No Estimate","Inaccurate Estimate"))
LOGIC:
If[(Est is between 1 to 3) and (Time = On Time) and (Quality = Good)], then it is "Accurate Estimate"
If[Est is 0], then it is "No Estimate"
Else it is "Inaccurate Estimate"

But strangely I have some rows classified as "Accurate Estimate" even if the Est column is 4. Is my formula wrongly specified?

Kindly let me know how I can correct this mistake.

Many thanks in advance


@amitchandak @Fowmy 
1 ACCEPTED SOLUTION
SteveCampbell
Memorable Member
Memorable Member

When you use OR || you must specify whole statements, not just one side.
E.G. Event[Est] = 1 ||  Event[Est] = 2  ||  Event[Est] =3
You could use IN instead.

 

Also, a SWITCH / TRUE() will be much easier to read

 

 

Estimate_Accuracy = 
SWITCH( TRUE(),
   (Event[Est] IN {1,2,3})  && (Event[Time] = "On Time") && (Event[Quality] = "GOOD")
      ,"Accurate Estimate"
   ,Event[Est]=0
      ,"No Estimate"
      ,"Inaccurate Estimate"
)

 

 

Make sure Event[Est] is numeric otherwise you will need to wrap all numbers in quotes in the DAX



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



View solution in original post

1 REPLY 1
SteveCampbell
Memorable Member
Memorable Member

When you use OR || you must specify whole statements, not just one side.
E.G. Event[Est] = 1 ||  Event[Est] = 2  ||  Event[Est] =3
You could use IN instead.

 

Also, a SWITCH / TRUE() will be much easier to read

 

 

Estimate_Accuracy = 
SWITCH( TRUE(),
   (Event[Est] IN {1,2,3})  && (Event[Time] = "On Time") && (Event[Quality] = "GOOD")
      ,"Accurate Estimate"
   ,Event[Est]=0
      ,"No Estimate"
      ,"Inaccurate Estimate"
)

 

 

Make sure Event[Est] is numeric otherwise you will need to wrap all numbers in quotes in the DAX



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors