Forum Discussion
Date Difference with a switch between two dates and One date and Today
- 5 years ago
Hey thereAnonymous, how about this one? If this one does not work try with a SWITCH() instead of an IF()!
IF( _status in {"completed", "removed"}, DATEDIFF ( _start_date, _end_date, DAY ), 0 )Hope this answer solves your problem! If you need any additional help please tag me in your reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️ or give it a kudoe 👍
Thanks!
Best regards,
Gonçalo Geraldes
Hello there! I would do something in the lines of the following!
Days Elapsed =
var _status = SELECTEDVALUE(projects[Status])
var _start_date = SELECTEDVALUE(projects[entry_date])
var _end_date = SELECTEDVALUE(projects[date_completed])
return
IF(
_status = "Not completed",
DATEDIFF(_start_date, _end_date, DAY),
0)
Hope this answer solves your problem! If you need any additional help please tag me in your reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️ or give it a kudoe 👍
Thanks!
Best regards,
Gonçalo Geraldes
Hey goncalogeraldes , it almost works, however, I have other categories in
project[Status]
I have completed, in-progress, not started, removed, on-hold, returned.
So I wanted to get rid of completed projects and removed projects from the measure. I have implemented it as the following below but still some projects seeing pass.
IF ( _status <> "completed" || _status <> "removed" , DATEDIFF ( _start_date, _end_date, DAY ), 0 )
Assist in this please.
- goncalogeraldes5 years ago
Super User
Hey thereAnonymous, how about this one? If this one does not work try with a SWITCH() instead of an IF()!
IF( _status in {"completed", "removed"}, DATEDIFF ( _start_date, _end_date, DAY ), 0 )Hope this answer solves your problem! If you need any additional help please tag me in your reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️ or give it a kudoe 👍
Thanks!
Best regards,
Gonçalo Geraldes