calculating the average Time Taken, with consecutive days and multiple employees

AudyAnalyst

New Member
Joined
Nov 24, 2021
Messages
20
Office Version
  1. 365
Platform
  1. Windows
Can anyone help create a formula showing the average length of time taken for each employee? For Example, "EMP2000" took 5/22 (1), 5/19 (1), 5/11 (1), & 3/3-3/1 (3), so, "EMP2000" average time off was (6/4) =1.5 days. The formula needs to be mindful of both the employee ID and the date Taken being sequential/consecutive.

Book3
ABC
1Employee IDTime Off DateApproved
2EMP20005/22/20238
3EMP20005/19/20238
4EMP20005/11/20238
5EMP20003/3/20238
6EMP20003/2/20238
7EMP20003/1/20238
8EMP20072/1/20234
9EMP20075/26/20238
10EMP20094/6/20238
11EMP20095/19/20238
12EMP20095/20/20238
13EMP20093/10/20238
14EMP20093/9/20238
15EMP20093/8/20234
16EMP20093/1/20234
17EMP20091/11/20234
18EMP20161/5/20234
19EMP20165/12/20238
20EMP20165/11/20238
21EMP20164/14/20238
22EMP20164/15/20238
23EMP20701/3/20238
24EMP20705/17/20238
25EMP20702/10/20238
26EMP20702/9/20235.25
27EMP20702/8/20238
28EMP20702/7/20238
29EMP20702/6/20238
Sheet1
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I have a resolution, but it's a bit clunky...

Dates taken v2.xlsx
ABCDEFGHIJKLMNOPQ
1Employee IDTime Off DateApprovedDate AboveDate BelowIf 1?Seq?True SeqMax in SeqIf more than Max number and 0 or 1If greater than 1 than number if not ""
2EMP20005/22/20238000010011Employee ID
3EMP20005/19/20238000010011EMP20002
4EMP20005/11/2023800001000 EMP20071
5EMP20003/3/2023810112000 EMP20092
6EMP20003/2/2023811123000 EMP20162.5
7EMP20003/1/20238011344444EMP20703.5
8EMP20072/1/20234000010011
9EMP20075/26/20238000010011
10EMP20094/6/20238000010011
11EMP20095/19/2023800001000 
12EMP20095/20/2023800012000 
13EMP20093/10/2023810123000 
14EMP20093/9/2023811134000 
15EMP20093/8/20234011455555
16EMP20093/1/20234000010011
17EMP20091/11/20234000010011
18EMP20161/5/2023400001000 
19EMP20165/12/2023810112000 
20EMP20165/11/20238011233333
21EMP20164/14/2023800001000 
22EMP20164/15/20238000122222
23EMP20701/3/20238000010011
24EMP20705/17/2023800001000 
25EMP20702/10/2023810112000 
26EMP20702/9/20235.2511123000 
27EMP20702/8/2023811134000 
28EMP20702/7/2023811145000 
29EMP20702/6/20238011566666
Sheet1
Cell Formulas
RangeFormula
D2:D29D2=IF(AND(A2=A3,B2=B3+1),1,0)
F2:F29F2=IF(AND(D2=0,E2=0),0,1)
H2:H29H2=G2+1
I2:J29I2=IF(H2>H3,H2,0)
K2:K29K2=IF(H3>=2,0,H2)
L2:L29L2=IF(K2>=1,K2,"")
E3:E29E3=IF(AND(A3=A2,B3=B2-1),1,0)
G3:G29G3=IF(OR(F3=1,AND(A3=A2,B3=B2+1)),G2+1,0)
Q3:Q7Q3=AVERAGEIF(A2:A29,P3,L2:L29)
 

Attachments

  • 1685677492874.png
    1685677492874.png
    36.1 KB · Views: 5
Upvote 0
Hi, see the linked file (with an auxiliary column) for a possible solution...

The formulas used in the table...

D2: =IF(A2="","",IFERROR(IF(AND(A2=A1,B2=B1-1),0,1),1)) (Range: D2:D30 ...)
F2: =UNIQUE(A2:A29)
G2: =IFERROR(COUNTIF(A:A,F2)/SUMIF(A:A,F2,D:D),0) (Range: G2:G6)

TimeAverage.xlsx

TimeAverage.png
 
Upvote 0
Is your actual data really like your ample data?
I ask because in the sample of it below, the consecutive yellow days go up the column whereas the consecutive green days go down the column. :confused:
Is there any consistency with your actual data?

1685695639892.png
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,331
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top