Count number of unique countries per company

D4rwin

Board Regular
Joined
Mar 31, 2014
Messages
91
Hi,

I have a table of unique emails with corresponding company and country.
I want to have a column which counts the number of unique countries a company is active in.

Column D is where I want the count to be in. Can someone help me with a formula for this?

[TABLE="class: grid, width: 100, align: left"]
<tbody>[TR]
[TD]Email[/TD]
[TD]Company[/TD]
[TD]Country[/TD]
[TD]#Countries[/TD]
[/TR]
[TR]
[TD]xxx[/TD]
[TD]A[/TD]
[TD]France[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD]xxx[/TD]
[TD]A[/TD]
[TD]Germany[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD]xxx[/TD]
[TD]A[/TD]
[TD]UK[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD]xxx[/TD]
[TD]B[/TD]
[TD]France[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]xxx[/TD]
[TD]B[/TD]
[TD]France[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]xxx[/TD]
[TD]C[/TD]
[TD]Germany[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]xxx[/TD]
[TD]C[/TD]
[TD]UK[/TD]
[TD="align: center"]2[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
In D2 control+shift+enter, not just enter, and copy down:

=SUM(IF(FREQUENCY(IF(1-($C$2:$C$8=""),IF($A$2:$A$8=$A2,MATCH($C$2:$C$8,$C$2:$C$8,0))),ROW($C$2:$C$8)-ROW($C$2)+1),1))
 
Upvote 0

Book1
ABCD
1EmailCompanyCountry#Countries
2xxxAFrance3
3xxxAGermany3
4xxxAUK3
5xxxBFrance1
6xxxBFrance1
7xxxCGermany2
8xxxCUK2
Sheet1
Cell Formulas
RangeFormula
D2{=SUM(--(FREQUENCY(IF($B$2:$B$8=$B2,MATCH($C$2:$C$8,$C$2:$C$8,0)),ROW($C$2:$C$8)-ROW($C$2)+1)>0))}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Upvote 0
Thanks for the responses. Should have specified that I am allergic to array formulas.
Any other nifty way using sumproduct perhaps?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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