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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Hossam
Regular Visitor

Subtract between two row in the same column via Custom Column

Hello 

 

Id like to subtract these two values  to get the amount of minutes the order took from statues pending to statues in kitchen via a custom column

 

Hossam_0-1614011641459.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Hossam 

You can do it in dax with an easy calculate column then change the format to TIME.

 

Column = IF([Status after]="in_kitchen",[Created at] - CALCULATE(MAX('Table'[Created at]),FILTER('Table',[ID]=EARLIER([ID])-1)))
 

V-pazhen-msft_0-1614231880543.png

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@Hossam 

You can do it in dax with an easy calculate column then change the format to TIME.

 

Column = IF([Status after]="in_kitchen",[Created at] - CALCULATE(MAX('Table'[Created at]),FILTER('Table',[ID]=EARLIER([ID])-1)))
 

V-pazhen-msft_0-1614231880543.png

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

 

 

amitchandak
Super User
Super User

@Hossam , Create a new column like

 


new column =
var _min = maxx(filter(Table, [order_id] = earlier([order_id]), [created_date] <earlier([created_date]) && [Status_after] = "pending"),[created_date])
return
if([Status_after] = "in_kitchen", datediff(_min, [created_date], minute))

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

Hello, @amitchandak I want to do this for all of the rows no matter what the statues are because its a whole process of statues.

 

so basically I want to subtract the second row of the column created at with the cell above it

 

Think you Can help me?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.