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
Creative_tree88
Helper III
Helper III

Using IF statement with dates - issues!

I have two dates columns (Request Date and Event Date).  I need to calculate the time between each date, to identify how long clients have waited for their event.  However, in our data, if an event (appt) has not yet been made the default date which is returned is 01/01/2099.  So, when calculating days between, with a 'normal' date field, I get exactly what I need to see.  When I try to calculate days between when the 01/01/2099 is there, I obviously get nonsense days!! 

 

What I need to be able to do is replace all of the instances of 01/01/2099 in the event date column, with today's date (which will obviously change each day with refresh) or leave the event date in place if it's a 'normal date'.  

 

I've tried using IF but the calculated column simply returns 01/01/2099 and therefore doesn't appear to work!?  Any help would be greatly received:

 

Request DateEvent DateDays BetweenEvent Date using TODAY's dateCorrected Days Between
01/11/202201/01/20992782017/11/202216
02/11/202201/01/20992781917/11/202215
03/11/202207/11/2022407/11/20224
04/11/202215/11/20221115/11/202211
05/11/202208/11/2022308/11/20223

 

The final two columns is what I need my data to show!  Many thanks,

1 ACCEPTED SOLUTION
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Creative_tree88 -

add a calculated column as:

Column = 
IF(
    TableName[Event Date] = DATE(2099,1,1)
    ,TODAY() - TableName[Request Date]
    ,TableName[Event Date] - TableName[Request Date]
)

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

3 REPLIES 3
Creative_tree88
Helper III
Helper III

This is a great community forum.  Much appreciated!

ChrisMendoza
Resident Rockstar
Resident Rockstar

@Creative_tree88 -

add a calculated column as:

Column = 
IF(
    TableName[Event Date] = DATE(2099,1,1)
    ,TODAY() - TableName[Request Date]
    ,TableName[Event Date] - TableName[Request Date]
)

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Many thanks!  Works like a charm. 

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.