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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.