Stumped Ranking Question

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,941
Ok I was working on another problem and came across something that has stumped me and I haven't been able to solve it for the past 30 minutes.

Is it possible to rank these WITHOUT the use of a helper column, VBA or a UDF, only native Excel Formulas:
Excel Workbook
ABCDEFGH
32StoreName$ SpentHelper ColumnChanging D33 to sumifsChanging D33 to sumifs
33Store1jake64646666
34Store1jim1251253333
35Store1joe731014444
36Store1john631261111
37Store1joe281014444
38Store1john631261111
39Store2jake79792222
40Store2jim45733333
41Store2jim28733333
42Store2joe84841111
43Store2john71715555
Sheet3
Cell Formulas
RangeFormula
D33=SUMIFS($C$33:$C$43,$A$33:$A$43,A33,$B$33:$B$43,B33)
F33=COUNTIFS($A$33:$A$43,A33,$D$33:$D$43," > "&D33)+1
H33=COUNTIFS($A$33:$A$43,A33,$D$33:$D$43," > "&SUMIFS($C$33:$C$43,$A$33:$A$43,A33,$B$33:$B$43,B33))+1
#VALUE!

As you can see in F&G, I can do this with the use of the helper column, but would like to eliminate it. I can change the D33 single part to a sumifs and eliminate that, my problem is creating the array of values summed based on A&B, but collecting that in an array for ranking purposes.

I'm not sure if it is possible without the helper column, but just thought I'd ask.
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Using your posted example....Try this:

This ARRAY FORMULA, completed by pressing CTRL+SHIFT+ENTER (instead of just ENTER) returns the relative rank of the Name's cumulative $ Spent relative to the cumulative totals of other Names from the same store:
Code:
E33: =MATCH(SUMIFS($C$33:$C$43,$A$33:$A$43,A33,$B$33:$B$43,B33),INDEX(
LARGE(SUMIFS($C$33:$C$43,$A$33:$A$43,$A$33:$A$43,$B$33:$B$43,$B$33:$B$43)
*($A$33:$A$43=A33),ROW(INDIRECT("1:"&COUNTIF($A$33:$A$43,A33)))),0),0)
Copy E33 and paste into E34:E43

In the above example, these are the returned values:
E33: 6
E34: 3
E35: 4
E36: 1
E37: 4
E38: 1
E39: 2
E40: 3
E41: 3
E42: 1
E43: 5

Is that something you can work with?
 
Upvote 0
Since nobody I work with *ever* remembers to use CTRL+SHIFT+ENTER on array formulas, I avoid them whenever possible. I can often convert what would be an array-formula to a regular formula via the strategic insertion of INDEX functions. That would have been the case in this formula...but I couldn't avoid the C+S+E (and forgot to remove the INDEX function)

Consequently the formula should have been:
Code:
E33: =MATCH(SUMIFS($C$33:$C$43,$A$33:$A$43,A33,$B$33:$B$43,B33),
LARGE(SUMIFS($C$33:$C$43,$A$33:$A$43,$A$33:$A$43,$B$33:$B$43,$B$33:$B$43)
*($A$33:$A$43=A33),ROW(INDIRECT("1:"&COUNTIF($A$33:$A$43,A33)))),0)
 
Last edited:
Upvote 0
Actually...There *is* a way to avoid the C+S+E and use a regular formula!

Code:
E33: =MATCH(SUMIFS($C$33:$C$43,$A$33:$A$43,A33,$B$33:$B$43,B33),INDEX(LARGE(
INDEX(SUMIFS($C$33:$C$43,$A$33:$A$43,$A$33:$A$43,$B$33:$B$43,$B$33:$B$43)
*($A$33:$A$43=A33),0),INDEX(ROW(INDIRECT("1:"&COUNTIF($A$33:$A$43,A33))),0)
),0),0)
 
Upvote 0
Thank you very much I was close, but didn't think to use index, which is where I was getting thrown off trying to use an if statement.

This appears exactly what I have been trying to solve.
 
Upvote 0
very nice. and I learned something about the ability to avoid the C+S+E for sheets used by other people.

thanks Ron

Actually...There *is* a way to avoid the C+S+E and use a regular formula!

Code:
E33: =MATCH(SUMIFS($C$33:$C$43,$A$33:$A$43,A33,$B$33:$B$43,B33),INDEX(LARGE(
INDEX(SUMIFS($C$33:$C$43,$A$33:$A$43,$A$33:$A$43,$B$33:$B$43,$B$33:$B$43)
*($A$33:$A$43=A33),0),INDEX(ROW(INDIRECT("1:"&COUNTIF($A$33:$A$43,A33))),0)
),0),0)
 
Upvote 0
I posted a reply to the original question but made the assumption there that column B values would only repeat against the same column A value (e.g. for the examples here that John exists on a row with store 1 he couldn't also be on a store 2 row)

If that's the case and you rank as here then you could use this formula with CSE

=SUM((SUMIFS(C$33:C$43,B$33:B$43,B$33:B$43,A$33:A$43,A33)>SUMIFS(C$33:C$43,B$33:B$43,B33,A$33:A$43,A33))+0)+1

but for the equivalent of Ron's formula, allowing for names to repeat against any store this version will work

=SUM((SUMIFS(C$33:C$43,B$33:B$43,B$33:B$43,A$33:A$43,A$33:A$43)*(A$33:A$43=A33)>SUMIFS(C$33:C$43,B$33:B$43,B33,A$33:A$43,A33))+0)+1

but I would consider that as you are ranking the name within that store the second placed name shouldn't be ranked 3 just because the first place name appears twice (there should only be ranking gaps if different names are tied) so making that assumption you can add another element, i.e.

=SUM((SUMIFS(C$33:C$43,B$33:B$43,B$33:B$43,A$33:A$43,A$33:A$43)*(A$33:A$43=A33)*(MATCH($A$33:$A$43&$B$33:$B$43,$A$33:$A$43&$B$33:$B$43,0)=ROW(A$33:A$43)-ROW(A$33)+1)>SUMIFS(C$33:C$43,B$33:B$43,B33,A$33:A$43,A33))+0)+1
 
Upvote 0
Interesting...
Change the SUM to SUMPRODUCT in your second formula...and you don't need to C+S+E it...which I like:
Code:
E33: =SUMPRODUCT((SUMIFS(C$33:C$43,B$33:B$43,B$33:B$43,A$33:A$43,A$33:A$43)
*(A$33:A$43=A33)>SUMIFS(C$33:C$43,B$33:B$43,B33,A$33:A$43,A33))+0)+1

However, the 1st and 3rd formulas do require C+S+E and only work if the rows for individaual stores are grouped together. Whereas, the longer formulas I posted work for any order of stores. Either one may be preferable, depending on the certainty that the data will, or may not, be sorted.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,243
Members
449,075
Latest member
staticfluids

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