Count only unique values

cunningAce

Board Regular
Joined
Dec 21, 2017
Messages
91
Office Version
  1. 365
Platform
  1. Windows
Hi,

In the example below I want to be able to enter the date and have the formula return the number of unique ID's related to it.
So the result would be 9 in this case.

Thanks in advance for your help

ABCDE
1
1
1
2
2
2
3
4
5
6
6
7
7
7
8
8
9
9
9

<tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: #FFF2CC"]Date[/TD]
[TD="bgcolor: #FFF2CC"]ID[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFF2CC"]Date[/TD]
[TD="bgcolor: #FFF2CC"]Count[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"]18/06/2018[/TD]
[TD="align: right"][/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]10[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]11[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]12[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]13[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]14[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]15[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]16[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]17[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]18[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]19[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]20[/TD]
[TD="align: right"]18/06/2018[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>

 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Excel 2013/2016
ABCDE
1DateIDDateCount
26/18/201816/18/20189
36/18/20181
46/18/20181
56/18/20182
66/18/20182
76/18/20182
86/18/20183
96/18/20184
106/18/20185
116/18/20186
126/18/20186
136/18/20187
146/18/20187
156/18/20187
166/18/20188
176/18/20188
186/18/20189
196/18/20189
206/18/20189
Sheet3
Cell Formulas
RangeFormula
E2=SUMPRODUCT(1/COUNTIFS(B2:B20,B2:B20,A2:A20,A2:A20),N(A2:A20=D2))
 
Upvote 0
Hi,

Thanks for your response,
This works for the example but when I add to my data with new dates and IDs it doesn't work. Can help to amend?


Book1
ABCDE
1DateIDDateCount
218/06/2018119/06/2018#VALUE!
318/06/20181
418/06/20181
518/06/20182
618/06/20182
718/06/20182
818/06/20183
918/06/20184
1018/06/20185
1118/06/20186
1219/06/20181
1319/06/20182
1419/06/20183
1519/06/20184
1619/06/20185
1719/06/20186
1819/06/20187
1919/06/20188
2019/06/20189
Sheet1
Cell Formulas
RangeFormula
E2=SUM(IF(FREQUENCY(IF($A$2:$A$20=D2,$B$2:$B$20),$B$2:$B$20),1))
 
Upvote 0
Hi,

Thanks for your help. This works. The only downfall is my data is quite large and when I change the cell references to complete rows the calculation is incredibly slow
 
Upvote 0
Care to post the formula as you implement it?

I am using the Frequency formula that you suggested. I had replied to the other suggestion using product regarding calculation time.

I prefer the Frequency formula as its quick but doesn't work when I add dates and Ids to the data.
 
Upvote 0
Hi,

Thanks for your response,
This works for the example but when I add to my data with new dates and IDs it doesn't work. Can help to amend?


Book1
ABCDE
1DateIDDateCount
218/06/2018119/06/2018#VALUE!
318/06/20181
418/06/20181
518/06/20182
618/06/20182
718/06/20182
818/06/20183
918/06/20184
1018/06/20185
1118/06/20186
1219/06/20181
1319/06/20182
1419/06/20183
1519/06/20184
1619/06/20185
1719/06/20186
1819/06/20187
1919/06/20188
2019/06/20189
Sheet1
Cell Formulas
RangeFormula
E2=SUM(IF(FREQUENCY(IF($A$2:$A$20=D2,$B$2:$B$20),$B$2:$B$20),1))

I am using the Frequency formula that you suggested. I had replied to the other suggestion using product regarding calculation time.

I prefer the Frequency formula as its quick but doesn't work when I add dates and Ids to the data.

You need to confirm the formula with control+shift+enter, not just with enter. I have apparently forgotten to mention that.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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