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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register 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
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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.