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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
eWise
Helper II
Helper II

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()...)



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

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()...)



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks @Greg_Deckler . That worked.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors