Forum Discussion
Dunner2020
Post Prodigy
6 years agoDate difference when condition met
Hi there, I am calculating the date difference between two columns with a condition that if Date A column has '1/01/1900' then do not take the difference. Here is my code: Diff_in_days =...
- 6 years ago
Please try this expression
Diff_in_days = VAR retail_notify = MAX ( 'Outages'[Date B] ) VAR interuption_start = MAX ( 'Outages'[Date A] ) RETURN IF ( YEAR ( retail_notify ) > 1900, DATEDIFF ( interuption_start, retail_notify, DAY ) )If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
amitchandak
Super User
6 years agoDunner2020 , Try like
Diff_in_days =
Var retail_notify = MAX('Outages'[Date B])
Var interuption_start = MAX('Outages'[Date A])
RETURN
CALCULATE( DATEDIFF(retail_notify,interuption_start,DAY), FILTER('Outages and Interruptions',not(isblank(retail_notify)) && retail_notify <> DATE(1900,01,01))
)