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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Gap Time for One Column Timestamp

Hello,

 

I've been stuck on this issue. So basically the challenge that I have is, I have a column of Timestamp and I want to know the gap in betweem the timestamp and the next time stamp (see table below).

 

To make it more clear, the goal is to subtract A3 to A2 and thats the results on C2 and so forth. Ive done this in excel I wonder how to do this on PowerBI DAX. Need help on this thanks!

 

 ABC 
1TimeStampHourResults 
21/18/20 6:1660:01:02 
31/18/20 6:1760:42:30 
41/18/20 7:0070:00:01 
51/18/20 7:0070:00:55 
61/18/20 7:0170:00:44 
71/18/20 7:0170:00:10 
81/18/20 7:0270:58:05 
91/18/20 8:0080:00:34 
101/18/20 8:0080:00:29 
111/18/20 8:0180:00:40 
121/18/20 8:0180:00:29 
131/18/20 8:0280:00:06 
141/18/20 8:0280:58:03 
151/18/20 9:0090:00:07 
161/18/20 9:009#REF!<-- error need iferror
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Not exact, but try.

diff =
datediff(table[Fecha del evento],max(filter(table,table[hour] =earlier(table[hour]) && table[TimeStamp] < earlier(table[TimeStamp])
&& table[Evento] = "BAJA-DEFINITIVA"),table[TimeStamp]),MINUTE)

OR

diff =
datediff(table[Fecha del evento],max(filter(table,table[hour] =earlier(table[hour]) && table[ID] < earlier(table[ID]-1)
&& table[Evento] = "BAJA-DEFINITIVA"),table[TimeStamp]),MINUTE)

 

Change as per need

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

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

1 REPLY 1
amitchandak
Super User
Super User

Not exact, but try.

diff =
datediff(table[Fecha del evento],max(filter(table,table[hour] =earlier(table[hour]) && table[TimeStamp] < earlier(table[TimeStamp])
&& table[Evento] = "BAJA-DEFINITIVA"),table[TimeStamp]),MINUTE)

OR

diff =
datediff(table[Fecha del evento],max(filter(table,table[hour] =earlier(table[hour]) && table[ID] < earlier(table[ID]-1)
&& table[Evento] = "BAJA-DEFINITIVA"),table[TimeStamp]),MINUTE)

 

Change as per need

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.