Count Unique Values That Meet Criteria

masouder

Board Regular
Joined
Jul 5, 2013
Messages
118
Office Version
  1. 2013
Platform
  1. Windows
I am attempting to count the unique values in one column where a criteria is met in another column. (Assume the following data starts in cell A1.) I want to count the number of different Names in Office 1. (The answer is 3: Joe, Lisa and Betty.) I don't think the COUNTIFS function will work, but I suspect the SUMPRODUCT function would. How can I accomplish this?

[TABLE="width: 195"]
<colgroup><col span="2"><col></colgroup><tbody>[TR]
[TD]Office[/TD]
[TD]Name[/TD]
[TD]Sale $[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Joe[/TD]
[TD]$100[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Sally[/TD]
[TD]$200[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Joe[/TD]
[TD]$300[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Mark[/TD]
[TD]$100[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Lisa[/TD]
[TD]$400[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Betty[/TD]
[TD]$200[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Lisa[/TD]
[TD]$100[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Mark[/TD]
[TD]$300[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Lisa[/TD]
[TD]$500[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Sally[/TD]
[TD]$200[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
[TABLE="class: grid"]
<tbody>[TR]
[TD][/TD]
[TD]
A
[/TD]
[TD]
B
[/TD]
[TD]
C
[/TD]
[TD]
D
[/TD]
[TD]
E
[/TD]
[/TR]
[TR]
[TD]
1
[/TD]
[TD]Office[/TD]
[TD]Name[/TD]
[TD]Sale $[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
2
[/TD]
[TD]
1​
[/TD]
[TD]Joe[/TD]
[TD]
100​
[/TD]
[TD][/TD]
[TD]
3​
[/TD]
[/TR]
[TR]
[TD]
3
[/TD]
[TD]
2​
[/TD]
[TD]Sally[/TD]
[TD]
200​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
4
[/TD]
[TD]
1​
[/TD]
[TD]Joe[/TD]
[TD]
300​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
5
[/TD]
[TD]
2​
[/TD]
[TD]Mark[/TD]
[TD]
100​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
6
[/TD]
[TD]
1​
[/TD]
[TD]Lisa[/TD]
[TD]
400​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
7
[/TD]
[TD]
1​
[/TD]
[TD]Betty[/TD]
[TD]
200​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
8
[/TD]
[TD]
1​
[/TD]
[TD]Lisa[/TD]
[TD]
100​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
9
[/TD]
[TD]
2​
[/TD]
[TD]Mark[/TD]
[TD]
300​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
10
[/TD]
[TD]
1​
[/TD]
[TD]Lisa[/TD]
[TD]
500​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
11
[/TD]
[TD]
2​
[/TD]
[TD]Sally[/TD]
[TD]
200​
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


E2=
SUM(IF(FREQUENCY(IF(A2:A11=1,MATCH(B2:B11,B2:B11,0)),ROW(B2:B11)-ROW(B2)+1),1))

Control+Shift+Enter
 
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