Question

suppose; i am having the following table:

Group   Nam ID  Score    Rank
London  B   1   88
London  C   2   7
London  A   3   45
London  D   4   23
London  E   5   2
London  F   6   56
Sydney  C   1   7
Sydney  B   2   98
Sydney  A   3   12
Tokyo   R   1   45
Tokyo   Z   2   23
Tokyo   A   3   56
Tokyo   G   4   86
Tokyo   E   5   19

I would like to fill the rank column with a formulae such that i can get the rank for each group individually. the formulae i am currently using is the first row of rank column is:

=RANK(D2,$D$2:$D$7,1)

i can drag the formulae till the end of london group but the for sydney group or for any new group i am entering a new formulae to define the reference range parameter of the rank formulae.

is there any easy way to do this? so that i can input a single formulae into Rank columns first row and drag till of the table... i am to do this over 17000 records. some rules; group column is sorted, id column is sorted asc.

thanks

Was it helpful?

Solution

some rules: group column is sorted, id column is sorted asc.

Try this formula:

=RANK(D2,INDEX(D:D,MATCH(A2,A:A,0)):INDEX(D:D,MATCH(A2,A:A,0)+COUNTIF(A:A,A2)-1),1)

where A:A is your "Group" column.

OTHER TIPS

One possibility is to use this formula in row 2 copied down

=COUNTIFS(A:A,A2,D:D,"<"&D2)+1

By counting rows which are in the same group as current row and with a lower score than the current row score you effectively get an "ascending rank" but with ranking starting at zero, hence +1 to make ranking start at 1 as per usual

simoco's solution may be more efficient for sorted values - this works even if nothing is sorted

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top