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
eWise
Advocate I
Advocate I

IF Statement with blank dates

Hi all,

Can someone help me with this, 

Am trying to create an adjusted date based on the current date and time where when the time is past 1 pm, the adjusted date is the following day at 7 am. It works fine until where there is a blank date the it gives me really off date like below.

 

Hare is my if stsatement;

AdjustedDeliveryTime =
 
IF('Order'[PickedUpTime] > TIME(13,00,00), INT('Order'[delivered]) + 1 + TIME(7,0,0), 'Order'[delivered])
 
Here is a snapshot of what am getting. Notice the 1899 date. Thanks for the help.
 
eWise_0-1620162622401.png

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@eWise Right, DAX base reference date is midnight, 12/30/1899. Why? No idea, just is. So, BLANK() = 0 = 12/30/1899 00:00:00.

 

So, makes total sense what is going on. Try this:

 

 

AdjustedDeliveryTime =
IF(ISBLANK('Order'[delivered],BLANK(),IF('Order'[PickedUpTime] > TIME(13,00,00), INT('Order'[delivered]) + 1 + TIME(7,0,0), 'Order'[delivered]))

 

 

If you hate nested IF statements, use SWITCH(TRUE()...)


@ 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...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@eWise Right, DAX base reference date is midnight, 12/30/1899. Why? No idea, just is. So, BLANK() = 0 = 12/30/1899 00:00:00.

 

So, makes total sense what is going on. Try this:

 

 

AdjustedDeliveryTime =
IF(ISBLANK('Order'[delivered],BLANK(),IF('Order'[PickedUpTime] > TIME(13,00,00), INT('Order'[delivered]) + 1 + TIME(7,0,0), 'Order'[delivered]))

 

 

If you hate nested IF statements, use SWITCH(TRUE()...)


@ 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...

Thanks @Greg_Deckler . That worked.

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.