cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
Solution Specialist
Solution Specialist

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
Solution Specialist
Solution Specialist

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
Solution Specialist
Solution Specialist

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors