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?

EmailCompanyCountry#Countries
xxxAFrance3
xxxAGermany3
xxxAUK3
xxxBFrance1
xxxBFrance1
xxxCGermany2
xxxCUK2

<tbody>
</tbody>
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,138
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))
 

wideboydixon

Well-known Member
Joined
Jun 2, 2016
Messages
3,401
<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style="font-weight: bold;;">Email</td><td style="font-weight: bold;;">Company</td><td style="font-weight: bold;;">Country</td><td style="font-weight: bold;;">#Countries</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">xxx</td><td style=";">A</td><td style=";">France</td><td style="text-align: right;;">3</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">xxx</td><td style=";">A</td><td style=";">Germany</td><td style="text-align: right;;">3</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">xxx</td><td style=";">A</td><td style=";">UK</td><td style="text-align: right;;">3</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style=";">xxx</td><td style=";">B</td><td style=";">France</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style=";">xxx</td><td style=";">B</td><td style=";">France</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">7</td><td style=";">xxx</td><td style=";">C</td><td style=";">Germany</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">8</td><td style=";">xxx</td><td style=";">C</td><td style=";">UK</td><td style="text-align: right;;">2</td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">D2</th><td style="text-align:left">{=SUM(<font color="Blue">--(<font color="Red">FREQUENCY(<font color="Green">IF(<font color="Purple">$B$2:$B$8=$B2,MATCH(<font color="Teal">$C$2:$C$8,$C$2:$C$8,0</font>)</font>),ROW(<font color="Purple">$C$2:$C$8</font>)-ROW(<font color="Purple">$C$2</font>)+1</font>)>0</font>)</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />

WBD
 

D4rwin

Board Regular
Joined
Mar 31, 2014
Messages
91
Thanks for the responses. Should have specified that I am allergic to array formulas.
Any other nifty way using sumproduct perhaps?
 

Forum statistics

Threads
1,082,451
Messages
5,365,609
Members
400,841
Latest member
roadtoexcel

Some videos you may like

This Week's Hot Topics

Top