Forum Discussion

Buster's avatar
Buster
Frequent Visitor
6 years ago
Solved

Time duration between rows in same column

I am very new to BI and attempting some self paced learning. I have read through a few posts here to assiust with solving my problem but with no succes as yet.

 

Attempting to calculate time duration between rows  of the same column and create a new "duration" column.

 

Picture attached for context.

4 Replies

  • It's not really clear from your question, but I'm guessing you just want to sort the times and calculation the difference from the current row to prior one. If so you could do something like the following to calculation the duration in minutes:

     

     

    Duration Mins = 
    var _currentTime = Table1[Timestamp] var _previousTime = maxx( filter(VALUES(Table1[Timestamp]), Table1[Timestamp] < _currentTime), [Timestamp]) return if (_previousTime = 0, blank(), DATEDIFF( _previousTime, _currentTime, MINUTE))

     

     

    • Buster's avatar
      Buster
      Frequent Visitor

      Thanks d_gosbell  and apologies for the lack of clarity

      I am attempting to create a new column in the querry editor that produces a time difference/duration time based on current row to the preceeding row of the Arrival Time column after the Arrival Time column has been sorted in Ascending order.

      your solution allowed me to create a time difference column  by creating a new column if modelling but I can not sort the Arrival Time in Ascending order as the arrival time is sorted in Date Hierarchy format Year/Quarter/Month/Day