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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

calculate the date difference between rows by group

Hi everyone

 

I have a table and I am trying to find the date difference by order ID between stages of an order.

 

JustB_0-1656464354318.png

I would like a column which tells me the number of days an order waits at each stage. As an example order_ID 1 was at stage A on 01 Jan and then stage B at 14 Jan, therefore the number of days at stage A is 13 days.

 

your assistance is appreciated

 

order_IDstagedate allocatedDays  at stage
1A1/01/2022 0:0013
1B14/01/2022 0:001
1C15/01/2022 0:00date now - date allocated
2A2/01/2022 0:00 
2C6/01/2022 0:00 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , New Column

 

=

Datediff([Date], minx(filter(Table, [order_ID] =earlier([order_ID] ) && [Date] > earlier([Date]) ) , [Date]), Day)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , New Column

 

=

Datediff([Date], minx(filter(Table, [order_ID] =earlier([order_ID] ) && [Date] > earlier([Date]) ) , [Date]), Day)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

thank you

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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