Forum Discussion

kheldar's avatar
kheldar
Iron Contributor
Mar 03, 2022
Solved

Calculate Duration Up Until A Specific Interval

Hello,   I'm once again in need of your expertise.   We have a raw data source that lists an employee's status in intervals. It lists the data as Start Time and End Time. I need to sum the durati...
  • mtarler's avatar
    mtarler
    Mar 04, 2022

    mathetes I think the 'complexity' comes in because of the range chosen. So I believe kheldar  wants to sum all the time on 'Moderation' UP TO the end of the selected range.
    Some of the issues I see here include:
    original formula was looking at [Name] when it should have been looking at [Email]
    the range drop down is very hard to work with. why not just use an end time that is either actual time format or at least is text that can be easily converted (as opposed to TIMEVALUE(RIGHT([dropdown],5))
    as for how to calculate I think you need to create a conditional duration:
    =sumproduct( (check name)*(check activity)*
                   if( [end time]<=[drop down],
                         [duration],
                         if ( [start time]<[drop down],
                                 [drop down] - [start time],
                                  0
                         )
                  )
       )
    assuming you have Excel 365 I did it using LET() so

    =LET(dTime,INT(MIN(RawMMP[End Time]))+TIMEVALUE(RIGHT($V$6,5)),
               SUMPRODUCT((RawMMP[Email]="Random Employee 1")*(RawMMP[Status]="Moderation Task")*
                  (IF( RawMMP[End Time]<=dTime,
                        RawMMP[Duration],
                         IF( RawMMP[Start Time] < dTime,
                            dTime - RawMMP[Start Time], 0)
               ))))

Resources