View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default how to find ranking value of one column grouped on another col

Hi,

I'm glad that worked and thanks for the feedback. If you want to figure out
how it works by yourself then don't read on but if you want help then this is
how it works


=SUMPRODUCT(--(C1<($A$1:$A$9=A1)*$C$1:$C$9))+1

This bit
$A$1:$A$9=A1 tells the formula what to include in each calculation
and returns the array so only the first 2 elements will count when
evaluating A1
{TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FAL SE}

In Excel TRUE and FALSE as boolean values can be considered to be 1 or 0 and
in fact in the formula are forced to 1 or 0 by the double unary but that's
another subject. So, this array is multipled by the numbers in column C. As
only the first 2 elements are counting we'll ignore the rest and get

TRUE;TRUE * 10.3;10.1 = 10.3;10.1

Each number greater than A1 returns 1 and the rest return zero so we get an
array of zeroes which are added up to make zero to which one is added to make
C1 rank as 1

The processs is then repeated for A2 producing the array

{TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FA LSE})

This is added up and =1 to which 1 is added which makes C2 rank as 2

Probably not the clearest explanation in the world but I hope it helps.

Mike

"zerocred" wrote:

Thats it! - Thanks!

I see now I screwed up my example - your numbers in brackets are right, mine
are wrong.

I have to figure out how sumproduct does it...
Cheers!