5 largest sums and corresponding value

Nebula2121

New Member
Joined
Apr 1, 2016
Messages
32
Hi. I need help. Example Data in column A - C. Desired Results E-F. I am looking to return the 5 largest sums based on a column and return the corresponding value. Thoughts?

ABCDEF
1FL200MN700
2TX200CO500
3FL100FL400
4FL100TX400
5MN400CA200
6MA100
7TX200
8CA100
9CA100
10CO500
11MN300
12NY100

<tbody>
</tbody>
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
well you could use consolidate to combine all the amounts for each state then sort for high to low. Or use large to obtain top 5 IE =Large(range,1),=Large(range,2)=Large(range,3),=Large(range,4),=Large(range,5)
 
Last edited:
Upvote 0
My first recommendation would be to create a SUMIF table in columns H & I (or wherever).
I'm pretty good with excel formulas, but summing each state and finding the top 5 in one fluid step would be ... "difficult."

Then I would use this to get the "Top 5":
F1 would be =LARGE(I:I,1)
F5 would be =LARGE(I:I,5)
**assuming each state is in column H & each total is in column I

Then I would use ↓this↓ to create your outputs in column E based on the top 5 in column F
Try this...

PS - You can click the arrows next to Valko's name to go to his post in another thread. Just in case you hadn't realized that yet or something.
 
Last edited:
Upvote 0

Book1
BCDEF
1statevalueN5
2FL200state count7
3TX200Nth Value200
4FL100adjusted N5
5FL100statetotal value
6MN400MN700
7MA100CO500
8TX200FL400
9CA100TX400
10CA100CA200
11CO500
12MN300
13NY100
Sheet1


F1: 5 (desired Top N)

In F2 control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(1-($B$2:$B$13=""),MATCH($B$2:$B$13,$B$2:$B$13,0)),ROW($B$2:$B$13)-ROW($B$2)+1),1))

In F3 control+shift+enter, not just enter:

=LARGE(SUMIFS($C$2:$C$13,$B$2:$B$13,IF(FREQUENCY(IF(1-($B$2:$B$13=""),MATCH($B$2:$B$13,$B$2:$B$13,0)),ROW($B$2:$B$13)-ROW($B$2)+1),$B$2:$B$13)),MIN(F1,F2))

In F4 control+shift+enter, not just enter:

=SUM(IF(SUMIFS($C$2:$C$13,$B$2:$B$13,IF(FREQUENCY(IF(1-($B$2:$B$13=""),MATCH($B$2:$B$13,$B$2:$B$13,0)),ROW($B$2:$B$13)-ROW($B$2)+1),$B$2:$B$13))>=F3,1))

This adjusts N for ties if applicable.

In E6 control+shift+enter, not just enter, and copy down:

=IF($F6="","",INDEX($B$2:$B$13,SMALL(IF(SUMIFS($C$2:$C$13,$B$2:$B$13,IF(FREQUENCY(IF(1-($B$2:$B$13=""),MATCH($B$2:$B$13,$B$2:$B$13,0)),ROW($B$2:$B$13)-ROW($B$2)+1),$B$2:$B$13))=$F6,ROW($B$2:$B$13)-ROW($B$2)+1),COUNTIFS($F$6:F6,F6))))

In F6 control+shift+enter, not just enter, and copy down:

=IF(ROWS($F$6:F6)>$F$4,"",LARGE(SUMIFS($C$2:$C$13,$B$2:$B$13,IF(FREQUENCY(IF(1-($B$2:$B$13=""),MATCH($B$2:$B$13,$B$2:$B$13,0)),ROW($B$2:$B$13)-ROW($B$2)+1),$B$2:$B$13)),ROWS($F$6:F6)))
 
Upvote 0
combine.jpg


I used consolidate to create Columns E & F

I used =INDEX($E$2:$F$8,MATCH(LARGE($F$2:$F$8,1),$F$2:$F$8,0),1) in H2 and =LARGE($F$2:$F$8,1) in I2 to show largest state and amount
I used =INDEX($E$2:$F$8,MATCH(LARGE($F$2:$F$8,2),$F$2:$F$8,0),1) in H2 and =LARGE($F$2:$F$8,2) in I3 to show 2nd largest state and amount and so on
 
Upvote 0

Forum statistics

Threads
1,215,123
Messages
6,123,183
Members
449,090
Latest member
bes000

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