Forum Discussion
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!
| A | B | C | ||
| 1 | TimeStamp | Hour | Results | |
| 2 | 1/18/20 6:16 | 6 | 0:01:02 | |
| 3 | 1/18/20 6:17 | 6 | 0:42:30 | |
| 4 | 1/18/20 7:00 | 7 | 0:00:01 | |
| 5 | 1/18/20 7:00 | 7 | 0:00:55 | |
| 6 | 1/18/20 7:01 | 7 | 0:00:44 | |
| 7 | 1/18/20 7:01 | 7 | 0:00:10 | |
| 8 | 1/18/20 7:02 | 7 | 0:58:05 | |
| 9 | 1/18/20 8:00 | 8 | 0:00:34 | |
| 10 | 1/18/20 8:00 | 8 | 0:00:29 | |
| 11 | 1/18/20 8:01 | 8 | 0:00:40 | |
| 12 | 1/18/20 8:01 | 8 | 0:00:29 | |
| 13 | 1/18/20 8:02 | 8 | 0:00:06 | |
| 14 | 1/18/20 8:02 | 8 | 0:58:03 | |
| 15 | 1/18/20 9:00 | 9 | 0:00:07 | |
| 16 | 1/18/20 9:00 | 9 | #REF! | <-- error need iferror |
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
1 Reply
- amitchandakSuper 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