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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.