Count Unique IDs for each Date

erenkey

Board Regular
Joined
Dec 9, 2005
Messages
162
I have a spreadsheet that contains customer IDs in Column A and Dates in Column B. Each customer can have the same date more than once. I am trying to count the unique IDs for each date. I tried using the following formula but it did not work:

=SUMPRODUCT(--($B$2:$B$59000=D$3),--(SUM(IF(FREQUENCY($A$2:$A$59000,$A$2:$A$59000)>0,1))))

Where Column A is the list of IDs
Column B is the list of Dates
Column D is the date I want to count.

Any ideas?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I have a spreadsheet that contains customer IDs in Column A and Dates in Column B. Each customer can have the same date more than once. I am trying to count the unique IDs for each date. I tried using the following formula but it did not work:

=SUMPRODUCT(--($B$2:$B$59000=D$3),--(SUM(IF(FREQUENCY($A$2:$A$59000,$A$2:$A$59000)>0,1))))

Where Column A is the list of IDs
Column B is the list of Dates
Column D is the date I want to count.

Any ideas?
With that many rows of data this will be very slow to calculate...

Array entered**:

=SUM(IF(FREQUENCY(IF(B2:B59000=D3,MATCH(A2:A59000,A2:A59000,0)),ROW(A2:A59000)-ROW(A2)+1),1))

** array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.

Assumes no empty cells within the data range.
 
Upvote 0
That works perfectly.

Now can I add something to it? What if I wanted to count how many IDs appear one time, two times or three times? An ID can only appear up to three times per date.
 
Upvote 0
That works perfectly.

Now can I add something to it? What if I wanted to count how many IDs appear one time, two times or three times? An ID can only appear up to three times per date.
If I understand what you want...

Just add the number like this:

=SUM(IF(FREQUENCY(IF(B2:B59000=D3,MATCH(A2:A59000,A2:A59000,0)),ROW(A2:A59000)-ROW(A2)+1)=n,1))

Where n = 1, 2, 3, whatever
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,277
Members
452,902
Latest member
Knuddeluff

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