Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

calculate time between two columns and different rows - turnaround calculation

I have two columns: In time and out time - the columns are formatted in date and time. I need to find the turnaround time in minutes (in time - previous out time).  I also want the turnaround time ...
  • v-jingzhang's avatar
    3 years ago

    Hi Anonymous 

     

    You can first add an Index column with Power Query Editor, then add a calculated column with below DAX. Change this TurnAround column to Decimal number data type. 

     

    TurnAround = 
    var _previousOutTime = MAXX(FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-1),'Table'[Out Time])
    var _previousOutDate = DATEVALUE(_previousOutTime)
    return
    IF(DATEVALUE('Table'[In Time])=_previousOutDate,'Table'[In Time]-_previousOutTime,BLANK())

     

     

    For delay time, you can create the following column. Also change its data type to decimal number. 

     

    Delay = 
    var _firstInTime = MINX(FILTER('Table',DATEVALUE('Table'[In Time])=DATEVALUE(EARLIER('Table'[In Time]))),'Table'[In Time])
    return
    IF('Table'[In Time]=_firstInTime, _firstInTime-(DATEVALUE('Table'[In Time])+TIME(8,0,0)), BLANK())

     

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.