Ranking Numbers With Criteria

austinandreikurt

Board Regular
Joined
Aug 25, 2020
Messages
91
Office Version
  1. 2016
Platform
  1. Windows
I have the set of numbers from A1 to A34:

2011330310120010231222214320513423
What I would like is to rank these numbers including the duplicates. But, for duplicate ones, I am using the numbers in Row 3 which is C3 to C34 to determine the rank of duplicates:

50356701010450050794665521398014481748

I used this formula "=RANK(A1,$A$1:$AH$1,0)+COUNTIF($A$1:A1,A1)-1" but this one will not consider the criteria set on Row 3
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I suggest to google for
stable sort criteria sumproduct sulprobil
and to apply the more complex example.
 
Upvote 0
Try this:

=RANK(A1,$A$1:$AH$1,0)+COUNTIFS($A$1:$AH$1,A1,$A$3:$AH$3,">"&A3)
 
Upvote 0
Hi Phuoc, It doesn't work properly, like for the #4 with 2 instances, the one with 17 as criteria became 2nd in rank and the one with 13 as criteria because 3rd in rank. It should be the other way around because 13 is lower than 17.
 
Upvote 0
Enter into E1
MrExcel_Ranking_with_criteria.xlsx
E
112
Tabelle1
Cell Formulas
RangeFormula
E1E1=SUMPRODUCT(--(A1<$A$1:$A$34))+SUMPRODUCT(--(A1=$A$1:$A$34),--(C1>$C$1:$C$34))+SUMPRODUCT(--(A1=$A$1:$A1),--(C1=$C$1:$C1))

and copy down.
 
Last edited:
Upvote 0
Maybe lie this:

=RANK(A1,$A$1:$AH$1,0)+COUNTIF($A$1:A1,A1)-1+COUNTIFS($A$1:$AH$1,A1,$A$3:$AH$3,"<"&A3)
 
Upvote 0
Maybe lie this:

=RANK(A1,$A$1:$AH$1,0)+COUNTIF($A$1:A1,A1)-1+COUNTIFS($A$1:$AH$1,A1,$A$3:$AH$3,"<"&A3)
The funny thing is: as soon as you use RANK, it's only numerical values you can rank. With COUNTIF(S) and SUMPRODUCT you can rank both strings and numbers.
 
Upvote 0
I can't believe its possible.
Seems like you have the result that you want (& there is confusion about whether your data is vertical or horizontal) but if this is true ...
I am using the numbers in ... C3 to C34 to determine the rank of duplicates:
.. just trying to understand why the green & yellow duplicates, with identical values in column C get ranked differently by 1 and the blue identical values with different values in column C also get ranked differently by 1? (Sulprobil's formula in column C)

20 09 04.xlsm
ABCDE
12512
20028
31322
41526
5364
6375
70029
831010
91120
100030
111423
122513
130031
140032
151527
160033
172718
18398
191424
202616
212617
222514
232515
241221
254132
26399
272819
280034
295141
301425
31386
324173
332411
34387
Rank
Cell Formulas
RangeFormula
E1:E34E1=SUMPRODUCT(--(A1<$A$1:$A$34))+SUMPRODUCT(--(A1=$A$1:$A$34),--(C1>$C$1:$C$34))+SUMPRODUCT(--(A1=$A$1:$A1),--(C1=$C$1:$C1))
 
Upvote 0
Hi Peter, Yes, sorry for the confusion on the data whether horizontal or vertical. It can still be both as I will just adjust the formula. For the Green and Yellow items you have mentioned, yes they will have to be ranked as the formula says because is should recognized the 1st instance of the same criteria as the higher rank which is similar in the Row 18 and 26 where Row 18 comes first than Row 26. The same for Row 31 and 34.
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top