Criteria Based Unique Records

gehusi

Board Regular
Joined
Jul 20, 2010
Messages
182
Hi everyone, I'm looking for a formula that will return the number of unique records that correspond to a separate criteria. As an example:

Column A Column B
Apple 123
Banana 123
Apple 101
Car 122
Banana 101
Apple 145
Apple 123


If the criteria value was "Apple", the formula should return 3 (123, 101, and 145). If it was "Banana", it would return 2 (123, 101).

Thanks in advance for your help!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I would use a pivot table. Did you try that?

Once you set-up a pivot table, you can update the pivot filter with the criteria you want, and the table will return the unique values.
 
Upvote 0
Hi everyone, I'm looking for a formula that will return the number of unique records that correspond to a separate criteria. As an example:

Column A Column B
Apple 123
Banana 123
Apple 101
Car 122
Banana 101
Apple 145
Apple 123


If the criteria value was "Apple", the formula should return 3 (123, 101, and 145). If it was "Banana", it would return 2 (123, 101).

Thanks in advance for your help!
If the data in column B really is numbers...

Array entered**:

=SUM(IF(FREQUENCY(IF(A2:A8="apple",B2:B8),B2:B8),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.
 
Upvote 0
If the data in column B really is numbers...

Array entered**:

=SUM(IF(FREQUENCY(IF(A2:A8="apple",B2:B8),B2:B8),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.
If the data in column B might not be numbers then here's a generic version (counts both text and numbers).

Still array entered:

=SUM(IF(FREQUENCY(IF(A2:A8="apple",MATCH(B2:B8,B2:B8,0)),ROW(B2:B8)-ROW(B2)+1),1))

Assumes no empty cells within the data range of column B.
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,777
Members
452,942
Latest member
VijayNewtoExcel

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