Index & Match with Sumproduct for repeated values

Amenendez

New Member
Joined
Mar 1, 2020
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Dear All,

I have the following data list with two main fields (Category and Country) for Year 1 and Year 2, that I want to get indexed in order from max to min, adding up the values for those categories repeated in the below table.

I would like to have i.e. For Year 1 and Country F the list from Max to Min of the Categories with the sum of the value.

I.e.(The list shall return me That Category C19 is the first one with 1,952 USD, followed by C11 with USD 480,...)

Can anyone support me with a formula for this, without using a Pivot Table?

Thanks
ABCDE
1CategoryCountryYear1Year 2Total
2C01F0.50.41.0
3C01F0.00.20.2
4C01F7.64.812.4
5C02F0.829.430.3
6C02F22.535.057.5
7C03F0.279.679.8
8C04F1.10.21.3
9C05F0.00.00.0
10C06F51.014.465.4
11C20F28.229.858.0
12C20F1.51.93.4
13C20F104.5145.8250.3
14C20F82.459.9142.3
15C07F0.10.10.2
16C07F21.616.638.2
17C08F1.81.53.3
18C09F51.440.091.5
19C10F42.050.892.8
20C10F0.10.30.5
21C10F3.21.54.7
22C11F480.0272.0752.0
23C12F17.527.745.2
24C12F0.30.30.6
25C12F69.622.792.3
26C12F59.055.1114.1
27C12F73.073.3146.3
28C13F128.5111.2239.8
29C14F34.624.459.0
30C15F0.00.10.2
31C16F44.211.555.7
32C17F0.015.415.4
33C19F391.0399.2790.2
34C19F814.4578.41,392.7
35C19F394.1649.51,043.6
36C19F102.5133.3235.8
37C19F250.9245.6496.6
38C18F0.90.61.5
39C01A0.50.41.0
40C01B0.00.20.2
41C01C7.64.812.4
42C02E0.829.430.3
43C02C22.535.057.5
44C03C0.279.679.8
45C04A1.10.21.3
46C05C0.00.00.0
47C06A51.014.465.4
48C20A28.229.858.0
49C20B1.51.93.4
50C20D104.5145.8250.3
51C20C82.459.9142.3
52C07B0.10.10.2
53C07C21.616.638.2
54C08C1.81.53.3
55C09C51.440.091.5
56C10A42.050.892.8
57C10B0.10.30.5
58C10C3.21.54.7
59C11A480.0272.0752.0
60C12A17.527.745.2
61C12B0.30.30.6
62C12D69.622.792.3
63C12E59.055.1114.1
64C12C73.073.3146.3
65C13C128.5111.2239.8
66C14A34.624.459.0
67C15C0.00.10.2
68C16A44.211.555.7
69C17C0.015.415.4
70C19A391.0399.2790.2
71C19B814.4578.41,392.7
72C19D394.1649.51,043.6
73C19E102.5133.3235.8
74C19C250.9245.6496.6
75C18A0.90.61.5
76Grand Total3,281.33,132.66,413.9
77
78
79
80Select YearYear 1
81
82Select CountryF
83
84
85
86CategoryUSD%%
87Category in Order 1USD sum for the category in Order 1
88Category in Order 2USD sum for the category in Order 20.0%
89Category in Order 3USD sum for the category in Order 30.0%
90Category in Order 4USD sum for the category in Order 40.0%
91Category in Order 5USD sum for the category in Order 50.0%
92Category in Order 6USD sum for the category in Order 60.0%
93Category in Order 7USD sum for the category in Order 70.0%
94Category in Order 8USD sum for the category in Order 80.0%
95Category in Order 9USD sum for the category in Order 90.0%
96Category in Order 10USD sum for the category in Order 100.0%
97Category in Order 11USD sum for the category in Order 110.0%
98Category in Order 12USD sum for the category in Order 120.0%
99Category in Order 13USD sum for the category in Order 130.0%
100Category in Order 14USD sum for the category in Order 140.0%
101Category in Order 15USD sum for the category in Order 150.0%
102Category in Order 16USD sum for the category in Order 160.0%
103Category in Order 17USD sum for the category in Order 170.0%
104Category in Order 18USD sum for the category in Order 180.0%
105Category in Order 19USD sum for the category in Order 190.0%
124 Total0.0%-
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Can anyone support me with a formula for this, without using a Pivot Table?
It could be done in a reasonably practical manner using formulas to show the results in order of the original list, but not to sort by subtotal.
If you want MAX to MIN by sum then you would need to use a pivot table or possibly power query, but not formulas.
 
Upvote 0
Thanks Jason, I know how to sort individual values but I could not find a way to sort by subtotal.
Much appreciated, anyway
 
Upvote 0
If you are happy with helper columns & have Dynamic array functions, how about

+Fluff.xlsm
ABCDEFGHIJKL
1CategoryCountryYear1Year 2TotalCatTotalCat Total
2C01F0.50.41FC018.1C191952.9
3C01F00.20.2Year1C0223.3C11480
4C01F7.64.812.4C030.2C12219.4
5C02F0.829.430.3C041.1C20216.6
6C02F22.53557.5C050C13128.5
7C03F0.279.679.8C0651C0951.4
8C04F1.10.21.3C20216.6C0651
9C05F000C0721.7C1045.3
10C06F5114.465.4C081.8C1644.2
11C20F28.229.858C0951.4C1434.6
12C20F1.51.93.4C1045.3C0223.3
13C20F104.5145.8250.3C11480C0721.7
14C20F82.459.9142.3C12219.4C018.1
15C07F0.10.10.2C13128.5C081.8
16C07F21.616.638.2C1434.6C041.1
17C08F1.81.53.3C150C180.9
18C09F51.44091.5C1644.2C030.2
19C10F4250.892.8C170C050
20C10F0.10.30.5C191952.9C150
21C10F3.21.54.7C180.9C170
22C11F480272752
23C12F17.527.745.2
24C12F0.30.30.6
25C12F69.622.792.3
26C12F5955.1114.1
27C12F7373.3146.3
28C13F128.5111.2239.8
29C14F34.624.459
30C15F00.10.2
31C16F44.211.555.7
32C17F015.415.4
33C19F391399.2790.2
34C19F814.4578.41,392.70
35C19F394.1649.51,043.60
36C19F102.5133.3235.8
37C19F250.9245.6496.6
38C18F0.90.61.5
39C01A0.50.41
40C01B00.20.2
41C01C7.64.812.4
42C02E0.829.430.3
43C02C22.53557.5
44C03C0.279.679.8
45C04A1.10.21.3
46C05C000
47C06A5114.465.4
48C20A28.229.858
49C20B1.51.93.4
50C20D104.5145.8250.3
51C20C82.459.9142.3
52C07B0.10.10.2
53C07C21.616.638.2
54C08C1.81.53.3
55C09C51.44091.5
56C10A4250.892.8
57C10B0.10.30.5
58C10C3.21.54.7
59C11A480272752
60C12A17.527.745.2
61C12B0.30.30.6
62C12D69.622.792.3
63C12E5955.1114.1
64C12C7373.3146.3
65C13C128.5111.2239.8
66C14A34.624.459
67C15C00.10.2
68C16A44.211.555.7
69C17C015.415.4
70C19A391399.2790.2
71C19B814.4578.41,392.70
72C19D394.1649.51,043.60
73C19E102.5133.3235.8
74C19C250.9245.6496.6
75C18A0.90.61.5
76Grand Total3,281.303,132.606,413.90
Data
Cell Formulas
RangeFormula
H2:H21H2=UNIQUE(FILTER(A2:A75,B2:B75=G2))
I2:I21I2=SUMIFS(INDEX(C2:D75,0,MATCH(G3,C1:D1,0)),A2:A75,H2#,B2:B75,G2)
K2:L21K2=SORT(H2#:I2,2,-1)
Dynamic array formulas.
 
Upvote 0
I've been trying a few things without the new UNIQUE, FILTER and SORT functions, this works with the sample, but not sure how well it would handle a much larger volume of data.

Book12345 (version 1).xlsb
ABCDEFGHI
1CategoryCountryYear1Year 2TotalSelect YearYear1
2C01F0.50.41
3C01F00.20.2Select Countryf
4C01F7.64.812.4
5C02F0.829.430.3
6C02F22.53557.5
7C03F0.279.679.8CategoryUSD%
8C04F1.10.21.3C191952.963.946%
9C05F000C1148015.717%
10C06F5114.465.4C12219.47.184%
11C20F28.229.858C20216.67.092%
12C20F1.51.93.4C06511.670%
13C20F104.5145.8250.3C1045.31.483%
14C20F82.459.9142.3C1434.61.133%
15C07F0.10.10.2C0223.30.763%
16C07F21.616.638.2C0721.70.711%
17C08F1.81.53.3C018.10.265%
18C09F51.44091.5C180.90.029%
19C10F4250.892.8C030.20.007%
20C10F0.10.30.5C1700.000%
21C10F3.21.54.7C1500.000%
22C11F480272752   
23C12F17.527.745.2   
24C12F0.30.30.6   
25C12F69.622.792.3   
26C12F5955.1114.1   
27C12F7373.3146.3Total3054100.00%
28C13F128.5111.2239.8
29C14F34.624.459
30C15F00.10.2
31C16F44.211.555.7
32C17F015.415.4
33C19F391399.2790.2
34C19F814.4578.41,392.70
35C19F394.1649.51,043.60
36C19F102.5133.3235.8
37C19F250.9245.6496.6
38C18F0.90.61.5
39C01A0.50.41
40C01B00.20.2
41C01C7.64.812.4
42C02E0.829.430.3
43C02C22.53557.5
44C03C0.279.679.8
45C04A1.10.21.3
46C05C000
47C06A5114.465.4
48C20A28.229.858
49C20B1.51.93.4
50C20D104.5145.8250.3
51C20C82.459.9142.3
52C07B0.10.10.2
53C07C21.616.638.2
54C08C1.81.53.3
55C09C51.44091.5
56C10A4250.892.8
57C10B0.10.30.5
58C10C3.21.54.7
59C11A480272752
60C12A17.527.745.2
61C12B0.30.30.6
62C12D69.622.792.3
63C12E5955.1114.1
64C12C7373.3146.3
65C13C128.5111.2239.8
66C14A34.624.459
67C15C00.10.2
68C16A44.211.555.7
69C17C015.415.4
70C19A391399.2790.2
71C19B814.4578.41,392.70
72C19D394.1649.51,043.60
73C19E102.5133.3235.8
74C19C250.9245.6496.6
75C18A0.90.61.5
76Grand Total3,281.303,132.606,413.90
Sheet4
Cell Formulas
RangeFormula
H8:H26H8=IF(H7="","",IFERROR(AGGREGATE(14,6,IF(ISNA(MATCH($A$2:$A$75,$G$7:$G7,0)),SUMIFS(INDEX($C$2:$E$75,0,MATCH($H$1,$C$1:$E$1,0)),$A$2:$A$75,$A$2:$A$75,$B$2:$B$75,$H$3),""),ROWS(H$8:H8)),""))
I8:I26I8=IF(H8="","",H8/SUM($H$8:$H$26))
H27:I27H27=SUM(H8:H26)
G8:G26G8=IF(H8="","",INDEX($A$2:$A$75,MATCH(2,1/ISNA(MATCH($A$2:$A$75,$G$7:$G7,0))/(SUMIFS(INDEX($C$2:$E$75,0,MATCH($H$1,$C$1:$E$1,0)),$A$2:$A$75,$A$2:$A$75,$B$2:$B$75,$H$3)=H8))))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
Another option without the helper columns

+Fluff.xlsm
ABCDEFGHI
1CategoryCountryYear1Year2TotalCatTotal
2C01F0.55001FC191952.9
3C01F00.20.2Year1C11480
4C01F7.64.812.4C12219.4
5C02F0.829.430.3C20216.6
6C02F22.53557.5C13128.5
7C03F0.279.679.8C0951.4
8C04F1.10.21.3C0651
9C05F000C1045.3
10C06F5114.465.4C1644.2
11C20F28.229.858C1434.6
12C20F1.51.93.4C0223.3
13C20F104.5145.8250.3C0721.7
14C20F82.459.9142.3C018.1
15C07F0.10.10.2C081.8
16C07F21.616.638.2C041.1
17C08F1.81.53.3C180.9
18C09F51.44091.5C030.2
19C10F4250.892.8C050
20C10F0.10.30.5C150
21C10F3.21.54.7C170
22C11F480272752
23C12F17.527.745.2
24C12F0.30.30.6
25C12F69.622.792.3
26C12F5955.1114.1
27C12F7373.3146.3
28C13F128.5111.2239.8
29C14F34.624.459
30C15F00.10.2
31C16F44.211.555.7
32C17F015.415.4
33C19F391399.2790.2
34C19F814.4578.41,392.70
35C19F394.1649.51,043.60
36C19F102.5133.3235.8
37C19F250.9245.6496.6
38C18F0.90.61.5
39C01A0.50.41
40C01B00.20.2
41C01C7.64.812.4
42C02E0.829.430.3
43C02C22.53557.5
44C03C0.279.679.8
45C04A1.10.21.3
46C05C000
47C06A5114.465.4
48C20A28.229.858
49C20B1.51.93.4
50C20D104.5145.8250.3
51C20C82.459.9142.3
52C07B0.10.10.2
53C07C21.616.638.2
54C08C1.81.53.3
55C09C51.44091.5
56C10A4250.892.8
57C10B0.10.30.5
58C10C3.21.54.7
59C11A480272752
60C12A17.527.745.2
61C12B0.30.30.6
62C12D69.622.792.3
63C12E5955.1114.1
64C12C7373.3146.3
65C13C128.5111.2239.8
66C14A34.624.459
67C15C00.10.2
68C16A44.211.555.7
69C17C015.415.4
70C19A391399.2790.2
71C19B814.4578.41,392.70
72C19D394.1649.51,043.60
73C19E102.5133.3235.8
74C19C250.9245.6496.6
75C18A0.90.61.5
76Grand Total3,281.303,132.606,413.90
Data
Cell Formulas
RangeFormula
H2:H21H2=SORTBY(UNIQUE(FILTER(A2:A75,B2:B75=G2)),SUMIFS(INDEX(C2:D75,0,MATCH(G3,C1:D1,0)),B2:B75,G2,A2:A75, UNIQUE(FILTER(A2:A75,B2:B75=G2))),-1)
I2:I21I2=SUMIFS(INDEX(C2:D75,0,MATCH(G3,C1:D1,0)),A2:A75,H2#,B2:B75,G2)
Dynamic array formulas.
 
Upvote 0
Thanks so much Fluff. I will take your last approach as it sorts out perfectly well my request.

Many thansks
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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