Forum Discussion

ryan_b_fiting's avatar
ryan_b_fiting
Icon for Post Patron rankPost Patron
4 years ago

Calculating Hours Logged but excluding Overlapping Time

Hi Community - 

I am in need of some help on how to calculate total hours logged, but excluding time stamps that are overlapping by employee.  Here is a sample of the data:

ticket_idEmployeecompany_nametimeStarttimeEndHours Logged
8222055465Company ABX7/5/2022 12:007/5/2022 20:008.0
8222055465Company ABX7/5/2022 14:007/5/2022 19:005.0

 

When I just SUM the hours here I get 13 hours, but the actual result I would want to see is 8 hours, because the entire 5 time log of the second row is overlapping the first log.

 

Is there a DAX measure that could do this so that I will not include any of the overlapping time stamps in my Hours Logged Calculation?  Note that these are not only perfect round hour overlaps, but also minutes and seconds.

 

Any help would be greatly appreciated as this is a time sensitive matter.

Thanks Community!

Ryan

2 Replies

  • ryan_b_fiting , Create a new column and use that

     


    var _next = minx(filter(Table, [Employee] = earlier([Employee]) && [ticket_id] = earlier([ticket_id]) && [timeStart] > earlier([timeStart]) ),[timeStart])
    return
    if(_next < [timeEnd], _next , [timeEnd])

    • ryan_b_fiting's avatar
      ryan_b_fiting
      Icon for Post Patron rankPost Patron

      Thanks amitchandak for the quick response.  Unfortunately that calculation does not work.  For that sample set of data, the result is only 7 hours.

      ticket_idEmployeecompany_nametimeStarttimeEndAdj_End_TimeHours LoggedAdj_Hours_log
      8222055465Company ABX7/5/2022 12:007/5/2022 20:007/5/2022 14:008.02.0
      8222055465Company ABX7/5/2022 14:007/5/2022 19:007/5/2022 19:005.05.0