-2

I have a list that looks like this:

Location   ID
______________
Boston     12
Boston     12
Boston     12
Boston     57
Boston     99
Chicago    12
Chicago    13
...

For each Location I want to count up the number of unique IDs. Boston would have 3 and Chicago would have 2 for example.

I can use Advanced filter by unique records but I want to know how to do this using an Excel formula.

KaliMa
  • 1,970
  • 6
  • 26
  • 51

1 Answers1

1

Use this array formula:

=SUM(IF($A$2:$A$8=D2,1/COUNTIFS($B$2:$B$8,$B$2:$B$8,$A$2:$A$8,D2)))

Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

enter image description here

Scott Craner
  • 148,073
  • 10
  • 49
  • 81