cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Datagulf
Resolver II
Resolver II

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

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
Super User
Super User

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

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 

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

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

Finally it works

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show Episode 10 Recap

The Power BI Community Show

Watch the playback when Amit Chandak, a Power BI Super User, demos how to use Field Parameters to make reports more dynamic.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.

Top Solution Authors