Excel equation explanation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have recently come across a use full equation that I use, however I am
perplexed about why it works. I am hoping someone can give me a clear
explanation, here it is:

{=sum(1/(countif(data,data))}

This is an array formula, used to count the distinct entries in a data set -
I know it works I just don't know why, and I have reduced it to subsets of
the equation but that just confused me more.

Thx, C
 
First of all, as written that formula is error prone if there can be any
blank cells in the range you are testing, this is a better way of using this
technique

=SUMPRODUCT(--(data<>""),1/COUNTIF(data,data&""))


now to the way it works

COUNTIF(data,data&"")

will return an array of numbers based on the values occurrence like for
instance

{1;3;1;3;3;1;1;1;1}

where 3 represent that particular value occurring 3 times and the rest of
the values 1 time

this part

1/COUNTIF(data,data&"")

using the same data will return

{1;0.333333333333333;1;0.333333333333333;0.333333333333333;1;1;1;1}

then if you sum that array it will return 6

1+1/3+1+1/3+1/3+1+1+1


--


Regards,


Peo Sjoblom
 
I believe it was former Excel MVP David Hager that came up with this, it was
mentioned in John Walkenbach's spreadsheet page in 1999. I can't believe
Neil Rubenking doesn't give credit to David.


--


Regards,


Peo Sjoblom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top