Sum the 10 largest values for ID

jevi

Active Member
Joined
Apr 13, 2010
Messages
339
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I have different columns and 150.000 rows, in column F I have the client ID, while in column BH I have the amount. I would like to have a formula (not a pivot table as I did it with Pivot) to sum only one amount but it should be included the amount per ID with the 10 nth largest amounts.

Example:

ID 10 it might be reapeated a lot of times in row F, so I need the sum of ID10 (all the amounts).

So i need the 10 largest amounts per ID just a sum of them all.

Thank you,
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Can you post some sample data along with the expected results.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Hi Pluff,

Sorry but I can't download as is my work PC:(. But i did an immagine so hopefully it can help.
So my result would be the column E, but it seemed I can't do it for ID like column C and D....honestly I don't need the column C and D detail but still would be nice to have it as they are only the first 10 nth ID with largest amount.
Thank you,
1652283010562.png
 
Upvote 0
Ok, ow about
++Fluff.xlsm
ABCDE
1
21012010117204520
310210102210
4101700126200
5126200130400
610110002230
7102200140
81304001810
922303000
10140200500
11181041400
123000520
13200500630
144140071
1552085
16630  
1771  
1885 
19
Main
Cell Formulas
RangeFormula
E2E2=SUMPRODUCT(--(D2:D20>=LARGE(D2:D20,10)),D2:D20)
C2:C17C2=IFNA(INDEX($A$2:$A$18,MATCH(0,COUNTIFS(C$1:C1,$A$2:$A$18),0)),"")
D2:D18D2=IF(C2="","",SUMIFS(B:B,A:A,C2))


The formula in C2 may need array entry for your version
 
Upvote 0
Solution
Ok, ow about
++Fluff.xlsm
ABCDE
1
21012010117204520
310210102210
4101700126200
5126200130400
610110002230
7102200140
81304001810
922303000
10140200500
11181041400
123000520
13200500630
144140071
1552085
16630  
1771  
1885 
19
Main
Cell Formulas
RangeFormula
E2E2=SUMPRODUCT(--(D2:D20>=LARGE(D2:D20,10)),D2:D20)
C2:C17C2=IFNA(INDEX($A$2:$A$18,MATCH(0,COUNTIFS(C$1:C1,$A$2:$A$18),0)),"")
D2:D18D2=IF(C2="","",SUMIFS(B:B,A:A,C2))


The formula in C2 may need array entry for your version
Hi Pluff,

Thank you for the formulas and they work great but the formula in column C i have 150.000 rows so it is heavy for the file. I was looking for something to give me the result of column E with the database of column A and B....so just have the result. Maybe is not possible so I will use the Pivot as I already did them but was hoping for a formula just to have the amount of the 10nth biggest import from the list.

Thank you,
 
Upvote 0
I Know of no way to just get the final result in one formula for your version of Excel.
 
Upvote 0
Hi Pluff,

I am sure you know better. I marked it as a solution as in a way it gives the result....maybe a Macro can do it faster than Pivot Tables and Formulas?

Thank you
 
Upvote 0
I have thought of a way of doing it in one formula, but suspect that a pivot would be better.
++Fluff.xlsm
ABCD
1CountyQty
2Surrey961364
3Greater London56
4Somerset35
5Bedfordshire65
6Greater London94
7Tyne and Wear41
8East Sussex7
9Hertfordshire54
10Cambridgeshire78
11Gloucestershire55
12Tyne and Wear92
13Lancashire6
14Hampshire82
15Greater London16
16Greater London30
17West Yorkshire67
18Hampshire35
19Greater London42
20Hertfordshire80
21Staffordshire7
22Tyne and Wear26
23Nottinghamshire80
24Wiltshire85
25Staffordshire96
26Derbyshire57
27Leicestershire42
28County Durham84
29Greater London25
30West Sussex77
31Greater London20
32Lincolnshire99
33Berkshire42
34Leicestershire1
35South Yorkshire2
36Surrey65
37Leicestershire55
38West Midlands17
39Nottinghamshire45
40Northamptonshire5
Main
Cell Formulas
RangeFormula
D2D2=SUM(LARGE(MMULT((A2:A40=TRANSPOSE(A2:A40))*(MMULT((ROW(1:39)>=TRANSPOSE(ROW(1:39)))*(A2:A40=TRANSPOSE(A2:A40)),ROW(1:39)^0)=1),B2:B40),ROW(1:10)))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
I have thought of a way of doing it in one formula, but suspect that a pivot would be better.
++Fluff.xlsm
ABCD
1CountyQty
2Surrey961364
3Greater London56
4Somerset35
5Bedfordshire65
6Greater London94
7Tyne and Wear41
8East Sussex7
9Hertfordshire54
10Cambridgeshire78
11Gloucestershire55
12Tyne and Wear92
13Lancashire6
14Hampshire82
15Greater London16
16Greater London30
17West Yorkshire67
18Hampshire35
19Greater London42
20Hertfordshire80
21Staffordshire7
22Tyne and Wear26
23Nottinghamshire80
24Wiltshire85
25Staffordshire96
26Derbyshire57
27Leicestershire42
28County Durham84
29Greater London25
30West Sussex77
31Greater London20
32Lincolnshire99
33Berkshire42
34Leicestershire1
35South Yorkshire2
36Surrey65
37Leicestershire55
38West Midlands17
39Nottinghamshire45
40Northamptonshire5
Main
Cell Formulas
RangeFormula
D2D2=SUM(LARGE(MMULT((A2:A40=TRANSPOSE(A2:A40))*(MMULT((ROW(1:39)>=TRANSPOSE(ROW(1:39)))*(A2:A40=TRANSPOSE(A2:A40)),ROW(1:39)^0)=1),B2:B40),ROW(1:10)))
Press CTRL+SHIFT+ENTER to enter array formulas.
Thank you so much Pluff....but really still Pivot is good I just was curios doing with a formula. Is not working at my file because I guess that they are rows that have zero in column B so that might be a reason...but no problem at all. Still great formula, you are such a genious :)
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,252
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