# Excel: Ranking multiple columns of TEXT data

Situation

I have two text columns: 'Group' and 'Colours' like below and I want to use a formula to generate a 'Rank' that restarts numbering with each different group

Group - Colour - Rank
A - Red - 1
A - Red - 1
A - Blue - 2
A - Blue - 2
A - Green - 3
B - Purple - 1
B - Purple - 1
B - Yellow - 2
B - Pink - 2
C - Orange - 1
C - Blue - 1

I have tried various different formula using both SUMPRODUCT and RANK.EQ but I have not been able to produce a working formula because both columns are TEXT.

RANK.EQ fails if I pass an array (conditional evaluated) as the 2nd argument so I can't use that. It only can't use that and only appears to accept a range object - not an array of values.

I have used INDEX with no rows or columns specified to return an array to avoid entering the formula as an array CSE formula.

Question

How can I use RANK.EQ or SUMPRODUCT to produce the results in a simple formula ? Any suggestions welcomed
LVL 3
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
you can simply use COUNTIFS to rank them.
0
Commented:
Hi,

pls try in C2

``````=IF(A4<>A3,-D3,0)+IF(AND(A4=A3,B4=B3),D3+0,D3+1)
``````
Regards
0
Author Commented:
ProfessorJimJam: Please provide an example as on the face of it COUNTIFS will 'count' multiple matches not 'rank' different matches - as shown in my example.
0
Author Commented:
Rgonzo1971: Sorry but that only produces '1' for the first row with a unique combination of colour and group. I am also not sure what column D has to do with this - unless there is an extra step you forgot to mention :)
0
Commented:
Corrected Formula in C2

``````=+IF(A2<>A1,-C1,0)+IF(AND(A2=A1,B2=B1),C1,C1+1)
``````

EDIT Herewith an example
EE20151117.xlsm
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Rgonzo1971: That looks good. A lesson not to get to caught up with a specific function

HOWEVER

I would still be interested if someone can advise how to get the 'Rannk.eq' function to work for my issue because this will provide a more robust solution. The two columns of text data are no GUARENTEED to be sorted and I would still rank of the colour within a group even if the colours in the group were randomly distributed e.g.

A - Red - 1
A - Blue - 2
A - Green - 3
A - Blue - 2
A - White - 4
A - Red  - 1
0
Commented:
personally, i do not believe you can do this with Rank.eq function. i think Rgonzo formula does a great job for this purpose
0
Author Commented:
Yes the formula from 'Rgonzo' is exactly what I needed !

The 'Rank.eq' function should be able to do this as it is what the function is supposed to be for !
0
Author Commented:
Simplest is always best !
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.