Rank a subset with duplicated values defined by another column

TCB13

New Member
Joined
Apr 28, 2022
Messages
2
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hello,

I'm trying to create a column with a rank of values based on a control column. I've posted this in StackOverflow but I feel this forum is more appropriate for the topic.

My data:

VBA Code:
(A)     (B)     (C)
Value   Control Rank
100     1       8
200     1       6
200     1       7
300     0       5
310     0       4
320     1       3
350     1       2
400     1       1

In col C I've used a combination of RANK and COUNTIF in order to get a general rank of all entries that accommodates duplicates:

lJvpq.png


Now how I can do a rank on col D that:

a) Only considers the values if the Control col B has the value 1
b) Also deals with duplicates in the same way.

My end goal is to have this:

L1bMr.png


In StackOverflow I was suggested the following formula:

Excel Formula:
=IFERROR(MATCH(A2,SORT(FILTER($A$2:$A$9,$B$2:$B$9>0),1,-1),0)+COUNTIF($A$2:A2,A2)-1,"")

Unfortunately it doesn't work if I've duplicate values in col A with different control numbers:

combine-images.jpg


Thank you very much.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Maybe something like this

Pasta1
ABC
1ValueControlRank
210016
320015
420014
53000 
63100 
732013
835012
940011
Plan1
Cell Formulas
RangeFormula
C2:C9C2=IF(B2=1,COUNTIFS(B$2:B$9,1,A$2:A$9,">"&A2)+COUNTIFS(B2:B$9,1,A2:A$9,A2),"")


M.
 
Upvote 0
Solution
Hi @Marcelo Branco thank you very much! It does work with a limited number of rows.

I can always replace A$9 with A$1048576 and have it sorting the entire sheet.

Thank you.
 
Upvote 0

Forum statistics

Threads
1,225,626
Messages
6,186,095
Members
453,337
Latest member
fiaz ahmad

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