Forum Discussion

64653463456greg's avatar
64653463456greg
Frequent Visitor
4 years ago
Solved

Time between operations

 I have a table with dates and times (see picture). The times represent an uptime for a component.   What I’d like to do is figure out a way to get a column of the downtime between operation...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi 64653463456greg ,

     

    It sounds like you want to subtract the start time of the current row from the end time of the previous row to get the intermediate downtime. Also group by Serial Number.

    You could create a calculated column like

    previous end time =
    MINX (
        FILTER (
            'Table',
            [Serial Number] = EARLIER ( 'Table'[Serial Number] )
                && [End Time] > EARLIER ( 'Table'[End Time] )
        ),
        [End Time]
    )
    

    Then create another calculated column to get the time.

    Time =
    IF (
        NOT ( ISBLANK ( [previous end time] ) ),
        [previous end time] - [Start Time]
    )
    

     

     

     

    Best Regards,

    Stephen Tao

     

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

  • 64653463456greg's avatar
    4 years ago

    Thank You Stephen for your answer.

    I found another way that worked great as well.

     

    What I did was:

    Create an Index column.

     

    Then based on that I made an “Next start time” table:

     

    Next Start Time = IF('Data'[Serial #] = LOOKUPVALUE('Data'[Serial #],'Data'[Index],'Data'[Index]+1),LOOKUPVALUE('Data'[Start Time],'Data'[Index],'Data'[Index]+1),BLANK())

     

    Then I made a column based on that for the downtime in minutes:

     

    Down Time (Minutes) = (DATEDIFF('Data'[End Time],'Data'[Next Start Time],MINUTE)+0) 

     

    This worked great for my need.

    Thank you for taking the time and replying, I really appreciate it.