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

Win a FREE 3 Day Ticket to FabCon Vienna. Apply now

Reply
Anonymous
Not applicable

How to calculate days wih DATEDIFF

Hi. 

 

I have three dates - a startdate(registered date), enddate and todays date. 

 

I would like to know how many days a case has been open. I have this equation: 

 = DATEDIFF(Data[Registreret dato], TODAY(), DAY)
 
However, it keeps calculating the number of days from the startdate even if the case has a enddate, so how do I remove the closed cases from the equation, so it only calculates number of days for the open cases? 

Best regards,
Lisa 
1 ACCEPTED SOLUTION
JorgePinho
Solution Sage
Solution Sage

= IF(ISBLANK(enddate),DATEDIFF(Data[Registreret dato], TODAY(), DAY))

View solution in original post

4 REPLIES 4
speedramps
Super User
Super User

Try this  ....

This will return blanks if the end date is populated ...

 

IF(ISBLANK(SELECTEDVALUE('Table'[EndDate])),
    DATEDIFF(
        SELECTEDVALUE('Table'[StartDate]),
        TODAY(),
         DAY))

or 

This will use the end date if populated or today date  ....

IF(ISBLANK(SELECTEDVALUE('Table'[End])),
DATEDIFF(
    SELECTEDVALUE('Table'[Start]),
    TODAY(),
    DAY),
DATEDIFF(
    SELECTEDVALUE('Table'[StartDate]),
    SELECTEDVALUE('Table'[EndDate]),
    DAY))        
 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

JorgePinho
Solution Sage
Solution Sage

= IF(ISBLANK(enddate),DATEDIFF(Data[Registreret dato], TODAY(), DAY))

Anonymous
Not applicable

Thank you 🙂 
However, how do I remove the "0" in the equation if the cell is blank? 🙂 

IF(ISBLANK(Data[Afsluttet dato]),DATEDIFF(Data[Registreret dato], TODAY(), DAY))

I didn't understand. Can you please show an image or explain in another way?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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