Hi K,
It's a nasty one isn't it?!
Basically it's an array formula, so it doesn't apply to one range once, but instead it applies to all cells in the array and works out the number of uniques from there.
Breaking it down:
=COUNTIF([range],[criteria])
- this formula has two variables, [range] and [criteria], which is the range you're analysing and the criteria you're finding within that range. The result is the number of times Excel finds the criteria value within the range.
For example: =COUNTIF(A2:A13,1) would tell you that there were X number of 1s in the range A2:A13.
=SUMPRODUCT(X)
- this is one of the best functions in Excel, quite honestly. You can use it as a SUMIF, but use multiple conditions, whereas SUMIF only allows you to give one condition.
- anyway, in this context, it's rather different. If you take the formula and apply it only to one cell (as opposed to the A2:A13 range), you get:=SUMPRODUCT((A2<>"")/COUNTIF(A2,A2&""))
which means "find the number of times A2 occurs in cell A2 [once] and divide the number of cells in the range A2 [one] by that number", i.e. 1 divided by 1 = 1. This will happen if you do the formula for one cell.
Ok, so where were we:
The full formula reads:=SUMPRODUCT((A2:A13<>"")/COUNTIF(A2:A13,A2:A13&""))
which literally says "look at the range A2:A13 and find each occurrence of each value and divide by the number of occurrences, then add each single occurrence together to get the number of unique values".
I hope that clears it up a little bit!!
Dave
Bookmarks