Consecutive week count with multiple conditions

Asuka

New Member
Joined
Jul 27, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am after some help to count the number of consecutive weeks an individual has been paid. Difficulties with the data set are the duplicates values. I have explored and trialled countifs but haven't been able to incorporate the portion around a consecutive count.

I've included an example dataset for reference:

In this example set, the output should be:
John Doe: 0 or blank
Jane Roe: 2
Tom Lee: 3

NamePayment Period
John Doe01/07/2020
John Doe15/07/2020
Jane Roe01/07/2020
Jane Roe01/07/2020
Jane Roe08/07/2020
Jane Roe08/07/2020
Jane Roe15/07/2020
Jane Roe15/07/2020
Tom Lee08/07/2020
Tom Lee08/07/2020
Tom Lee08/07/2020
Tom Lee15/07/2020
Tom Lee15/07/2020
Tom Lee22/07/2020
Tom Lee29/07/2020

Thank you!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try this
Book23
ABCDE
1NamePayment Period
2John Doe01-07-20John Doe0
3John Doe15-07-20Jane Roe2
4Jane Roe01-07-20Tom Lee3
5Jane Roe01-07-20
6Jane Roe08-07-20
7Jane Roe08-07-20
8Jane Roe15-07-20
9Jane Roe15-07-20
10Tom Lee08-07-20
11Tom Lee08-07-20
12Tom Lee08-07-20
13Tom Lee15-07-20
14Tom Lee15-07-20
15Tom Lee22-07-20
16Tom Lee29-07-20
Sheet1
Cell Formulas
RangeFormula
D2:D4D2=UNIQUE(A2:A16)
E2:E4E2=LET(_a,FILTER($B$2:$B$16,$A$2:$A$16=D2),_b,MAX(FREQUENCY(_a,_a)),IF(_b=1,0,_b))
Dynamic array formulas.
 
Upvote 0
Try this
Book23
ABCDE
1NamePayment Period
2John Doe01-07-20John Doe0
3John Doe15-07-20Jane Roe2
4Jane Roe01-07-20Tom Lee3
5Jane Roe01-07-20
6Jane Roe08-07-20
7Jane Roe08-07-20
8Jane Roe15-07-20
9Jane Roe15-07-20
10Tom Lee08-07-20
11Tom Lee08-07-20
12Tom Lee08-07-20
13Tom Lee15-07-20
14Tom Lee15-07-20
15Tom Lee22-07-20
16Tom Lee29-07-20
Sheet1
Cell Formulas
RangeFormula
D2:D4D2=UNIQUE(A2:A16)
E2:E4E2=LET(_a,FILTER($B$2:$B$16,$A$2:$A$16=D2),_b,MAX(FREQUENCY(_a,_a)),IF(_b=1,0,_b))
Dynamic array formulas.

Thank you - This works! Sorry to toss another spanner in the works.. is there a way to have this done in one formula? Something similar to the below?

NamePayment PeriodConsecutive week count
John Doe01/07/20200
John Doe15/07/20200
Jane Roe01/07/20200
Jane Roe01/07/20200
Jane Roe08/07/20201
Jane Roe08/07/20201
Jane Roe15/07/20202
Jane Roe15/07/20202
Tom Lee08/07/20200
Tom Lee08/07/20200
Tom Lee08/07/20200
Tom Lee15/07/20201
Tom Lee15/07/20201
Tom Lee22/07/20202
Tom Lee29/07/20203
 
Upvote 0
Oh, that was completely different from my last interpretation of your data.

Try this
Book57
ABC
1NamePayment PeriodConsecutive week count
2John Doe01-07-200
3John Doe15-07-200
4Jane Roe01-07-200
5Jane Roe01-07-200
6Jane Roe08-07-201
7Jane Roe08-07-201
8Jane Roe15-07-202
9Jane Roe15-07-202
10Tom Lee08-07-200
11Tom Lee08-07-200
12Tom Lee08-07-200
13Tom Lee15-07-201
14Tom Lee15-07-201
15Tom Lee22-07-202
16Tom Lee29-07-203
Sheet1
Cell Formulas
RangeFormula
C2:C16C2=IFERROR(XLOOKUP(A2&B2-7,A$1:A1&B$1:B1,C$1:C1,0),0)+SIGN(COUNTIFS(A$1:A1,A2,B$1:B1,B2-7))
 
Upvote 0
Solution
Sorry, that was my fault - I wasn't specific enough. This is perfect, exactly what I am after! Thank you so much for troubleshooting.
 
Upvote 0
Or try this:

Book1
ABC
1NamePayment PeriodConsecutive week count
2John Doe01/07/20200
3John Doe15/07/20200
4Jane Roe01/07/20200
5Jane Roe01/07/20200
6Jane Roe08/07/20201
7Jane Roe08/07/20201
8Jane Roe15/07/20202
9Jane Roe15/07/20202
10Tom Lee08/07/20200
11Tom Lee08/07/20200
12Tom Lee08/07/20200
13Tom Lee15/07/20201
14Tom Lee15/07/20201
15Tom Lee22/07/20202
16Tom Lee29/07/20203
Sheet1
Cell Formulas
RangeFormula
C2:C16C2=IF(A2<>A1,0,IF(B2-7=B1,C1+1,C1))
 
Upvote 0
Oops, I forgot part way through that my formula can deal with unsorted data, so there was no need for absolute references.
Excel Formula:
=IFERROR(XLOOKUP(A2&B2-7,A:A&B:B,C:C,0),0)+SIGN(COUNTIFS(A:A,A2,B:B,B2-7))
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,068
Members
449,091
Latest member
remmuS24

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