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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
wbarnes
Regular Visitor

Converting Excel IF/OR/AND statement to DAX

I have been trying to convert the below Excel nested IF statement to DAX, and I cannot seem to get anything to work for me, maybe I'm making this more complicated than it really is. I'm new to DAX and can't seem to make the transition from Excel formulas to DAX!!!! Hoping someone can help me. 

Here is my Excel If statement:  =IF(OR(B2=0, B2=""), "Due Date Not Assigned", IF(AND(D2>=A2,D2<=B2),"Yes","No"))

wbarnes_1-1672940615666.png

Any help would be greatly appreciated!!

1 ACCEPTED SOLUTION
adudani
Super User
Super User

Hi @wbarnes ,

 

Create the following calculated column using DAX.

adudani_0-1672948263110.png

 

Completed by DueDate =
IF( 'Table'[Due Date] = 0 || ISBLANK('Table'[Due Date]),
    "Due Date Not Assigned",
    IF( 'Table'[Completed Date]>= 'Table'[Assigned Date] && 'Table'[Completed Date]<= 'Table'[Due Date],"Yes","No"))
 
There are more efficient ways to do this with switch true statements. However, this should get the job done.

 

Appreciate a thumbs up if you found this helpful.

 

Please accept this solution if the query is resolved.



Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

View solution in original post

4 REPLIES 4
jewel_at
Helper II
Helper II

 

I think in DAX it will be something like this

 

Column = 
IF('Table'[B] =0 || 'Table'[B] = null, "Due Date Not Assigned", IF('Table'[D] >='Table'[A] && 'Table'[D] <= 'Table'[B]',"Yes","No"))

 

 

You can also just add a custom column that in Power Query

if([B] = 0 or [B] = null) then "Due Date Not Assigned" else if([D] >= [A] and [D] <= [B]) then "Yes" else "No"

 

Hope that helps! Let me know!

 

 

Jewel

Thank you for your suggestion, this works!

adudani
Super User
Super User

Hi @wbarnes ,

 

Create the following calculated column using DAX.

adudani_0-1672948263110.png

 

Completed by DueDate =
IF( 'Table'[Due Date] = 0 || ISBLANK('Table'[Due Date]),
    "Due Date Not Assigned",
    IF( 'Table'[Completed Date]>= 'Table'[Assigned Date] && 'Table'[Completed Date]<= 'Table'[Due Date],"Yes","No"))
 
There are more efficient ways to do this with switch true statements. However, this should get the job done.

 

Appreciate a thumbs up if you found this helpful.

 

Please accept this solution if the query is resolved.



Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

Both solutions worked, thank you so much for your help!

I ended up following your layout.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors