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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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