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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Datagulf
Responsive Resident
Responsive Resident

Measure to find oldest Project by subtracting oldest project and today

I have a table that looks like the one below. Each entry is a single project. 

Client NameProject Entry DateProject Completed DateAgeing in DaysProject Status
Client A22/01/201901/04/201969 daysCompleted
Client B13/07/2020  Ongoing
Client C17/06/202119/092021103 daysCompleted
Client D21/09/202129/09/20218 daysCompleted
Client E23/10/202106/01/202274 daysCompleted
CLient F27/01/2022  Ongoing

So I want to get the number of days of an ongoing project that has stayed the most. That project would probably be the one for Client B since it does not have a completed date and is the earliest. 

I am thinking Datediff would work with and then get a value of the highest using RankX , DENSE. I want to display that number of days on a card. Any assistance is highly appreciated. 

1 ACCEPTED SOLUTION
Adescrit
Impactful Individual
Impactful Individual

Oldest project = 
VAR __Date = CALCULATE (
    MIN ( 'Table'[Entry Date] ),
    FILTER (
        'table',
        'table'[Status] <> "completed"
            && 'table'[Status] <> "removed"
            && 'table'[Status] <> "cancelled"
    )
)
RETURN
    
    DATEDIFF( __Date, TODAY(), DAY)

Did I answer your question? Mark my post as a solution!
My LinkedIn

View solution in original post

5 REPLIES 5
Adescrit
Impactful Individual
Impactful Individual

How about this:

Oldest =
VAR __Days =
    MAXX (
        'Table',
        IF (
            ISBLANK ( 'Table'[Completed Date] ),
            DATEDIFF ( 'Table'[Entry Date], TODAY (), DAY ),
            DATEDIFF ( 'Table'[Entry Date], 'Table'[Completed Date], DAY )
        )
    )
RETURN
    __Days

Did I answer your question? Mark my post as a solution!
My LinkedIn
Datagulf
Responsive Resident
Responsive Resident

Thanks for this. However, it is somewhat not correct from my side's explanation. I have been able to extract a date with the oldest date of an ongoing project. The formula used is as follows. 

 

Oldest project =
CALCULATE (
    MIN ( 'table'[entry_date] ),
    FILTER (
        'table',
        'table'[Status] <> "completed"
            && 'table'[Status] <> "removed"
            && 'table'[Status] <> "cancelled"
    )
)

 

how can I subtract this date from today's Date using Today()? @Adescrit 

Adescrit
Impactful Individual
Impactful Individual

Oldest project = 
VAR __Date = CALCULATE (
    MIN ( 'Table'[Entry Date] ),
    FILTER (
        'table',
        'table'[Status] <> "completed"
            && 'table'[Status] <> "removed"
            && 'table'[Status] <> "cancelled"
    )
)
RETURN
    
    DATEDIFF( __Date, TODAY(), DAY)

Did I answer your question? Mark my post as a solution!
My LinkedIn
Datagulf
Responsive Resident
Responsive Resident

In my answer, it returns a blank. Not sure why. Thanks, though

Datagulf
Responsive Resident
Responsive Resident

Finally it works

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!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.