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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ConnorH
Employee
Employee

Finding days between two rows date values

This is kind of complex and I haven't been able to figure it out. I am trying to create a column that finds the number of days between a project status but the project ID must be the same. The project Establish date is held in a a project table. 

 

Project status starts at 1.0 and goes up to 4.0. I am able to calculate the number of days it took the project to get to the status it is at from when the project was created. I want to find the amount of time it may take to get from status 3.0 to 4.0 and so on. 

 

 

 

IDProject IDModified dateStatusDays from Project Established date

Days between Status (Column I am trying to create)

1113621/20/201.000
2113621/23/202.033
3145981/25/203.0155
4113621/30/203.0107
5145981/30/204.02510
1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @ConnorH ,

 

Create a Calculated Column

 

Column =
VAR _prevstage_sameprojId_date =
    CALCULATE (
        MAX ( 'Table1'[Modified date] ),
        FILTER (
            'Table1',
            'Table1'[Modified date]
                < EARLIER ( 'Table1'[Modified date] )
                && Table1[Project ID]
                    = EARLIER ( Table1[Project ID] )
        )
    )
RETURN
    DATEDIFF (
        _prevstage_sameprojId_date,
        'Table1'[Modified date],
        DAY
    )

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

View solution in original post

6 REPLIES 6
harshnathani
Community Champion
Community Champion

Hi @ConnorH ,

 

Create a Calculated Column

 

Column =
VAR _prevstage_sameprojId_date =
    CALCULATE (
        MAX ( 'Table1'[Modified date] ),
        FILTER (
            'Table1',
            'Table1'[Modified date]
                < EARLIER ( 'Table1'[Modified date] )
                && Table1[Project ID]
                    = EARLIER ( Table1[Project ID] )
        )
    )
RETURN
    DATEDIFF (
        _prevstage_sameprojId_date,
        'Table1'[Modified date],
        DAY
    )

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

I used this to calculate Days Between Loads and was wondering how I could add to it to also calculate if it was the last Load, then how many days since then to "today"?

I have a similar instance where I would really aprecaite your help.

 

I am trying to create a column that finds the number of workingdays (excluding weekends and bankholidays - I have a list of all bank holidays in a table) between Milestones but the Audit Review ID must be the same. I will need to calculate the difference between the End Day of Milestone 1 with the end date with Milestone 2 and so on... Not all Audit Reviews have an End Date for all 7 milestones, some only have a few as seen in example.

 

Audit Review IDMilestone TypeMilestone End Date
1234561. Background Research01/12/2021
1234562. Terms of Reference03/02/2022
1234563. Opening Meeting04/03/2022
1234564. Fieldwork and Closing Meeting21/03/2022
1234565. Draft Report25/03/2022
1234566. Management Responses29/03/2022
1234567. Final Report07/04/2021
2345671. Background Research01/01/2022
2345672. Terms of Reference03/01/2022
2345673. Opening Meeting04/02/2022
2345674. Fieldwork and Closing Meeting12/02/2022
3456781. Background Research01/01/2021
3456782. Terms of Reference23/01/2022

 

For example, I would expect a value of 5 for the difference between (4. Fieldwork & Closing Meeting) and (5. Draft Report) for Audit 123456.

 

Would apprecaite your help.

@GeorgeR1  : I have similiar kind of scenario. By any chance if you find any solution . Kindly, can you please post here.

amitchandak
Super User
Super User

@ConnorH , Try a new column like

datediff(Table[Date], minx(filter(Table,Table[Date] <earlier(Table[Date])) ,Table[Date]),day)

Greg_Deckler
Super User
Super User

See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.