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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors