Forum Discussion

ganapathya's avatar
ganapathya
Frequent Visitor
9 years ago
Solved

Difference hours between two columns one is first row and next is in another row

Start DateEnd datedowntime
08-06-201408:55:3508-06-201409:55:35 
08-06-201413:55:3508-06-201413:55:354

 

I want to calculate downtime in hrs based on the end date of first row and start date of the second row, also  at the start of everyday downtime value should be empty

  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi ganapathya,

     

    You can try to use below formula:

     

    down time = 
    DATEDIFF(MAXX(FILTER(ALL(Sheet2),[ID]=EARLIER(Sheet2[ID])&&[End date]<EARLIER(Sheet2[Start Date])),[End date]),[Start Date],HOUR)+0

     

     

     

    Regards,

    Xiaoxin Sheng

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ganapathya,

     

    I'd like to suggest you use power query to add a index column, then use this index column to calculate time diff.

     

    Calculate column:

    down time = DATEDIFF(MAXX(FILTER(ALL(Sheet6),[End date]<EARLIER(Sheet6[Start Date])),[End date]),[Start Date],HOUR)+0

     

     

    Regards,

    Xiaoxin Sheng

    • ganapathya's avatar
      ganapathya
      Frequent Visitor
      IDStart DateEnd datedowntime
      Machine 108-06-201408:55:3508-06-201409:55:354
      Machine 108-06-201413:55:3508-06-201415:55:351
      Machine 108-06-201416:55:3508-06-201417:55:352
      Machine 108-06-201419:55:3508-06-201423:55:350
      Machine 209-06-201400:30:0009-06-201401:30:002
      Machine 209-06-201403:30:0009-06-201405:30:002
      Machine 209-06-201407:30:0009-06-201423:59:590

       

      For this above table ,same Query will work or some change is  required please help me

      • ganapathya's avatar
        ganapathya
        Frequent Visitor

        No sir, it is not working downtime has showing different data, please check the below data

         provide the changes accordingly

        Chamber Starttimeendtimedowntime
        CH14/25/2016 9:00:11 pm4/26/2016 7:58:53 am0
        CH14/26/2016 8:28:21 Am4/26/2016 5:44:19 Pmendtime of row 1-starttime of row 2
        CH14/26/2016 6:37:08 Am4/27/2016 3:25:36 amendtime of row 2 -starttime of row3
        CH14/27/2016 4:03:24 am4/27/2016 12:57:32 amendtime of row 3-starttime of row 4
        CH14/27/2016 5:29:00 pm4/28/2016 2:44:38 amendtime of row 4 -starttime of row5
        ch14/28/2016 12:09:09pm4/28/2016 8:36:55pmendtime of row 5 -starttime of row 6