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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
logicscience2
Regular Visitor

calculate duration between date-time of consecutie date-time rows

I have data of this format :

logicscience2_0-1711906549015.png

 

during import the data is sorted by date-time column then the Index column is added. So regardless how the table is sorted after import, the index can maintain a reference to sequential date-time values.

 

I am trying to add the duration-between calculated column which will calculate the difference between two rows based on the index order so in the picture above the first row would be blank or error, the second row would be 235 (minutes), the third would be  52 (minutes) and so on. These values would stay correctly calculated regardless of the ordering on the table.

 

 

1 ACCEPTED SOLUTION
logicscience2
Regular Visitor

This solution seems to work:

 

DurationBetween =
VAR CurrentDateTime = df[date-time]
VAR NextDateTime =
CALCULATE(
MIN(df[date-time]),
FILTER(
df,
df[date-time] > CurrentDateTime
)
)
RETURN
IF(
ISBLANK(NextDateTime),
BLANK(),
(NextDateTime - CurrentDateTime)*24*60
)

View solution in original post

1 REPLY 1
logicscience2
Regular Visitor

This solution seems to work:

 

DurationBetween =
VAR CurrentDateTime = df[date-time]
VAR NextDateTime =
CALCULATE(
MIN(df[date-time]),
FILTER(
df,
df[date-time] > CurrentDateTime
)
)
RETURN
IF(
ISBLANK(NextDateTime),
BLANK(),
(NextDateTime - CurrentDateTime)*24*60
)

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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