Forum Discussion

GRN_VPR8's avatar
GRN_VPR8
Frequent Visitor
2 years ago
Solved

Finding the Time difference between two events on different rows

Hi, I have a table (an example of this table below as a real one is hundreds of thousands of records with more columns) as detailed below, and I am after a way of finding out the duration between two...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi GRN_VPR8 ,

     

    We can create calculated columns.

    Rank = RANKX(FILTER('Table','Table'[tm_id]=EARLIER('Table'[tm_id])),'Table'[event_time],,ASC,Dense)
    Column = 
    var _a= MINX(FILTER(ALLSELECTED('Table'),'Table'[tm_id]=EARLIER('Table'[tm_id]) && 'Table'[Rank]=EARLIER('Table'[Rank])-1),[event_time])
    var _b='Table'[event_time]
    var _c=DATEDIFF(_a,_b,SECOND)
    return IF(_a=BLANK(),BLANK(),_b-_a)

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.