Count of Consecutive Work Days

skoorBmaS

New Member
Joined
Feb 5, 2016
Messages
34
Hi Guys, I am trying to get a formula going which will show if an employee has worked over 6 consecutive days. The way in which my data is currently stored is like the following:

DATEWeekEmployeeHours Worked
01/05/1818Bill10:00
02/05/1818Bill14:00
03/05/1818Bill08:00
01/05/1818Phil10:00
02/05/1818Phil10:00
03/05/1818Phil10:00
04/05/1818Phil10:00
05/05/1818Phil10:00

<tbody>
</tbody>

I would like in another sheet to show if any employee has worked over 6 consecutive days within a week. Please note that the data may not always be inputted in chronological order or with the employees days being sorted together.

Does anyone have a way in which to do this?

Kind Regards
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Possibly something like this:


ABCDEFG
1DATEWeekEmployeeHours WorkedEmployeeLongest consecutive run
25/1/201818Bill10:00Bill4
35/2/201818Bill14:00Phil7
45/3/201818Bill8:00
55/1/201818Phil10:00
65/2/201818Phil10:00
75/3/201818Phil10:00
85/4/201818Phil10:00
95/5/201818Phil10:00
104-Maybill
116-Mayphil
128-Maybill
137-Mayphil

<tbody>
</tbody>
Sheet6

Array Formulas
CellFormula
G2{=MAX(FREQUENCY(IF($C$2:$C$20=F2,IF(ISNUMBER(MATCH($A$2:$A$20,ROW(INDIRECT(MIN($A$2:$A$20)&":"&MAX($A$2:$A$20))),0)),$A$2:$A$20)),IF(ISERROR(MATCH(ROW(INDIRECT(MIN($A$2:$A$20)-1&":"&MAX($A$2:$A$20)+1))&F2,$A$2:$A$20&$C$2:$C$20,0)),ROW(INDIRECT(MIN($A$2:$A$20)-1&":"&MAX($A$2:$A$20)+1)))))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



This will find the longest streak per person, within the whole range, regardless of week boundaries. If you want to look for a given week only, you could add another cell with an 18 in it, and I could adapt the formula to only consider data with an 18 in column B.

Let us know.
 
Upvote 0
With further reflection, I think the previous formula has some flaws, this should fix them:

Code:
=MAX(FREQUENCY(IF(ISNUMBER(MATCH(ROW(INDIRECT(MIN($A$2:$A$20)&":"&MAX($A$2:$A$20)))&F2,$A$2:$A$20&$C$2:$C$20,0)),ROW(INDIRECT(MIN($A$2:$A$20)&":"&MAX($A$2:$A$20)))),IF(ISERROR(MATCH(ROW(INDIRECT(MIN($A$2:$A$20)-1&":"&MAX($A$2:$A$20)+1))&F2,$A$2:$A$20&$C$2:$C$20,0)),ROW(INDIRECT(MIN($A$2:$A$20)-1&":"&MAX($A$2:$A$20)+1)))))
with Control+Shift+Enter.

If you want the version that uses a week number, then:

ABCDEFG
1DATEWeekEmployeeHours WorkedWeekEmployeeLongest con
secutive run
25/1/201818Bill10:0019Bill1
35/2/201818Bill14:00Phil2
45/3/201818Bill8:00
55/1/201818Phil10:00
65/2/201818Phil10:00
75/3/201818Phil10:00
85/4/201818Phil10:00
95/5/201818Phil10:00
104-May18bill
116-May19phil
128-May19bill
137-May19phil
14

<tbody>
</tbody>
Sheet6

Array Formulas
CellFormula
G2{=MAX(FREQUENCY(IF(ISNUMBER(MATCH(ROW(INDIRECT(MIN($A$2:$A$20)&":"&MAX($A$2:$A$20)))&F2&$E$2,$A$2:$A$20&$C$2:$C$20&$B$2:$B$20,
0
)
),ROW(INDIRECT(MIN($A$2:$A$20)&":"&MAX($A$2:$A$20)))
),IF(ISERROR(MATCH(ROW(INDIRECT(MIN($A$2:$A$20)-1&":"&MAX($A$2:$A$20)+1))&F2&$E$2,$A$2:$A$20&$C$2:$C$20&$B$2:$B$20,0)),ROW(INDIRECT(MIN($A$2:$A$20)-1&":"&MAX($A$2:$A$20)+1)))
)
)}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
Hi Eric,

Thank you so much for the above. I have gotten it to work perfectly in the way you showed above. However since then, I have added a few more columns onto my data, in which now Date starts at A3, Week at B3, Name at D3. Then the consecutive run area is now at P3. Within your formula, I have changed the formulas references to reflect those changes, however the formula does not work anymore. Could you please advise or am I missing something simple? The new formula is as below:

Code:
=MAX(FREQUENCY(IF(ISNUMBER(MATCH(ROW(INDIRECT(MIN($A$3:$A$5000)&":"&MAX($A$3:$A$5000)))&Q3,$A$3:$A$500&$D$3:$D$5000,0)),ROW(INDIRECT(MIN($A$3:$A$5000)&":"&MAX($A$3:$A$5000)))),IF(ISERROR(MATCH(ROW(INDIRECT(MIN($A$3:$A$5000)-1&":"&MAX($A$2:$A$5000)+1))&Q3,$A$3:$A$5000&$D$3:$D$5000,0)),ROW(INDIRECT(MIN($A$3:$A$5000)-1&":"&MAX($A$3:$A$5000)+1)))))

With further reflection, I think the previous formula has some flaws, this should fix them:

Code:
=MAX(FREQUENCY(IF(ISNUMBER(MATCH(ROW(INDIRECT(MIN($A$2:$A$20)&":"&MAX($A$2:$A$20)))&F2,$A$2:$A$20&$C$2:$C$20,0)),ROW(INDIRECT(MIN($A$2:$A$20)&":"&MAX($A$2:$A$20)))),IF(ISERROR(MATCH(ROW(INDIRECT(MIN($A$2:$A$20)-1&":"&MAX($A$2:$A$20)+1))&F2,$A$2:$A$20&$C$2:$C$20,0)),ROW(INDIRECT(MIN($A$2:$A$20)-1&":"&MAX($A$2:$A$20)+1)))))
with Control+Shift+Enter.
 
Upvote 0
Hi Eric,

Please ignore the above. Just as I sent you this, I realised my mistake and now have the formula working. Thank you so much for your help. :)

Hi Eric,

Thank you so much for the above. I have gotten it to work perfectly in the way you showed above. However since then, I have added a few more columns onto my data, in which now Date starts at A3, Week at B3, Name at D3. Then the consecutive run area is now at P3. Within your formula, I have changed the formulas references to reflect those changes, however the formula does not work anymore. Could you please advise or am I missing something simple? The new formula is as below:

Code:
=MAX(FREQUENCY(IF(ISNUMBER(MATCH(ROW(INDIRECT(MIN($A$3:$A$5000)&":"&MAX($A$3:$A$5000)))&Q3,$A$3:$A$500&$D$3:$D$5000,0)),ROW(INDIRECT(MIN($A$3:$A$5000)&":"&MAX($A$3:$A$5000)))),IF(ISERROR(MATCH(ROW(INDIRECT(MIN($A$3:$A$5000)-1&":"&MAX($A$2:$A$5000)+1))&Q3,$A$3:$A$5000&$D$3:$D$5000,0)),ROW(INDIRECT(MIN($A$3:$A$5000)-1&":"&MAX($A$3:$A$5000)+1)))))
 
Upvote 0

Forum statistics

Threads
1,215,232
Messages
6,123,763
Members
449,120
Latest member
Aa2

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