Numbering Unique Occurances

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,180
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
This is a small sample of the data that I have. I sorted the data based on Activity and then Date. What I am trying to do is to number each activity based on date. So
on 8/26/2010 activity A occured which makes occurance 1
on 11/2/2010 activity A occured so that is the second occurance.

Here is another example

on 8/26/2011 Activity B occured which makes the first occurance
on 11/2/2010 Activity B occured which makes the second occurance
on 11/3/2010 Activity B occured which makes the third occurance
on 11/4/2010 Activity B occured which makes the forth occurance


Below is a sample of how I would like the data layed out.

Thanks in advance Stephen.

Book1
ABCD
1DateActivityCount
28/26/2010a1
38/26/2010a1
48/26/2010a1
58/26/2010a1
68/26/2010a1
78/26/2010a1
811/2/2010a2
911/2/2010a2
1011/2/2010a2
1111/2/2010a2
1211/2/2010a2
1311/2/2010a2
148/26/2010b1
158/26/2010b1
1611/2/2010b2
1711/2/2010b2
1811/2/2010b2
1911/3/2010b3
2011/3/2010b3
2111/4/2010b4
2211/4/2010b4
239/14/2011c1
249/14/2011c1
259/15/2011c1
269/16/2011c2
279/17/2011c3
289/18/2011c4
299/19/2011c5
Sheet6
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try this in C2 (and fill down):

=IF(B2<>B1,1,IF(AND(A2=A1,B2=B1),C1,C1+1))

P.S., from rows 25-29, is your count off by 1?
 
Upvote 0
Jose_Chasez,

Thanks you so much! Your right it was off by 1. Thanks again! Much appreciated!
 
Upvote 0
Jose_Chasez,

I found a small bug in the formula

9/14/2011 c 1
9/14/2011 c 1
9/15/2011 c 2
9/16/2011 c 3
9/17/2011 c 4
9/18/2011 c 5
9/19/2011 c 6
9/19/2012 c 7
9/19/2012 c 7

the occurance continues for c when the last 2 dates have the same month and day but different year?

The last 2 dates should be occurance 1 since they have a different year.

9/19/2012 c 1
9/19/2012 c 1

Can anyone please fix this.
Thanks again Stephen



<html><head><title>Excel Jeanie HTML</title></head><body>
Excel Workbook
ABC
1DateActivityCount
28/26/2010a1
38/26/2010a1
48/26/2010a1
58/26/2010a1
68/26/2010a1
78/26/2010a1
811/2/2010a2
911/2/2010a2
1011/2/2010a2
1111/2/2010a2
1211/2/2010a2
1311/2/2010a2
148/26/2010b1
158/26/2010b1
1611/2/2010b2
1711/2/2010b2
1811/2/2010b2
1911/2/2010b2
2011/3/2010b3
2111/4/2010b4
2211/4/2010b4
239/14/2011c1
249/14/2011c1
259/15/2011c2
269/16/2011c3
279/17/2011c4
289/18/2011c5
299/19/2011c6
309/19/2012c7
319/19/2012c7
Sheet2


</body></html>

Should look like below:

<html><head><title>Excel Jeanie HTML</title></head><body>
Excel Workbook
ABC
1DateActivityCount
28/26/2010a1
38/26/2010a1
48/26/2010a1
58/26/2010a1
68/26/2010a1
78/26/2010a1
811/2/2010a2
911/2/2010a2
1011/2/2010a2
1111/2/2010a2
1211/2/2010a2
1311/2/2010a2
148/26/2010b1
158/26/2010b1
1611/2/2010b2
1711/2/2010b2
1811/2/2010b2
1911/2/2010b2
2011/3/2010b3
2111/4/2010b4
2211/4/2010b4
239/14/2011c1
249/14/2011c1
259/15/2011c2
269/16/2011c3
279/17/2011c4
289/18/2011c5
299/19/2011c6
309/19/2012c1
319/19/2012c1
Sheet2


</body></html>
 
Upvote 0
This seems to work. Hard-code "1" in cell C2. Insert this formula in C3 and drag down

=IF(OR(B3<>B2,AND(B3=B2,YEAR(A3)<>YEAR(A2))),1,IF(AND(A3=A2,B3=B2),C2,C2+1))
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,876
Members
452,949
Latest member
Dupuhini

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