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
smashbroski
Regular Visitor

IF(AND( Function comes back with Expression.Error

Hello Everyone,

 

I'm trying to do an IF (AND( DAX command within PowerBI and when I create a custom column and type the following it comes back with no errors.

 

errorIF_SLMJustification001.PNG

 

But when I apply it, it comes back with a error with IF

errorIF_SLMJustification002.PNG

 

I've tried almost every thinkable command possible and can't seem to figure out why it doesn't like IF, if, else if.

 

 

What I'm trying to do is similar to the excel command of =IF(AND($P8="Service Targets Breached",$K8<$O8),"Yes","")

 

Your wisdom is appreciated!

1 ACCEPTED SOLUTION
smashbroski
Regular Visitor

Hi @affan 

 

That didn't resolve the issue so I did some searching and the following worked for me

 

= Table.AddColumn(#"Removed Duplicates2", "SLM Justification", each if [SLM Status] = "Service Targets Breached" and [Last Resolved Date]<[#"Due Date/Time"] then "Justified" else null)

 

 

Found it kinda funny becuase I think I typed that a million times and it came back with errors.

 

 

Thanks for you help!

View solution in original post

3 REPLIES 3
smashbroski
Regular Visitor

Hi @affan 

 

That didn't resolve the issue so I did some searching and the following worked for me

 

= Table.AddColumn(#"Removed Duplicates2", "SLM Justification", each if [SLM Status] = "Service Targets Breached" and [Last Resolved Date]<[#"Due Date/Time"] then "Justified" else null)

 

 

Found it kinda funny becuase I think I typed that a million times and it came back with errors.

 

 

Thanks for you help!

Greg_Deckler
Super User
Super User

That's because you are entering DAX when you should be using M...you shouldn't do that...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
affan
Solution Sage
Solution Sage

Hi @smashbroski 

 

Please try the below DAX

 

IF([SLM Status]="Service Target Breached",
    IF([Last Resolved Date]<[#"Due Date/Time"], "Justified",null),null)

 

If this does not work please share your sample file.

 

If this helped you, please mark this post as an accepted solution and like to give KUDOS .

 

Regards,

Affan Farooqi

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