Rank table highest positive to lowest positive first, then lowest negative to highest negative.

Mr_Stern

New Member
Joined
Feb 26, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm looking for a formula to use in a table ranking values.
It's a bit of an odd ranking that I can't manage to get quite right.

The values have both positive and negative numbers.
It would need to rank highest positive to lowest, then Lowest to highest negative.

E.g.
rank value
1) 20
2) 15
3) 10
4) -40
5) -12
6) -2

Kind regards
 
Hello, you might test:

Excel Formula:
=LET(
a,A1:A6,
SORTBY(a,IF(a>=0,1,2),1,ABS(a),-1))
 
Upvote 0
Hello, you might test:

Excel Formula:
=LET(
a,A1:A6,
SORTBY(a,IF(a>=0,1,2),1,ABS(a),-1))
Thanks but not quite what I'm after. The formula does well in sorting the values accordingly, but I need it to assign a value to the numbers. I suppose how I presented the question was confusing. Below is a better example
rank value
2) 15
4) -40
6) -2
1) 20
5) -12
3) 10
 
Upvote 0
Ah, I see, my bad then. The question remains how to handle ties - see how this will work:

Excel Formula:
=LET(
a,A1:A6,
r,SEQUENCE(ROWS(a)),
s,SORTBY(a,IF(a>=0,1,2),1,ABS(a),-1),
XLOOKUP(a,s,r))
 
Upvote 0
Does this do what you want?

(BTW, can your data include zero values? If so, how/where should they be ranked?)

25 03 20.xlsm
AB
1No.Rank
2152
3-404
4-26
5201
6-125
7103
Rank
Cell Formulas
RangeFormula
B2:B7B2=LET(d,A2:A7,a,ABS(d)+IF(d>0,10^9),XMATCH(a,SORT(a,,-1)))
Dynamic array formulas.
 
Upvote 0

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