Find Largest Value (then associate) via Multiple Sums

B1313

New Member
Joined
Sep 20, 2015
Messages
32
Hello,

So, I have a relatively simple request. I have the following table.

[TABLE="width: 555"]
<tbody>[TR]
[TD]Sizes:[/TD]
[TD]Red[/TD]
[TD]Blue[/TD]
[TD]Green[/TD]
[TD]Yellow[/TD]
[TD]Black[/TD]
[TD]White[/TD]
[TD]Purple[/TD]
[TD]Orange[/TD]
[TD]Brown[/TD]
[/TR]
[TR]
[TD]Total[/TD]
[TD]5[/TD]
[TD]1[/TD]
[TD]16[/TD]
[TD]15[/TD]
[TD]21[/TD]
[TD]12[/TD]
[TD]7[/TD]
[TD]9[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Item 1[/TD]
[TD]2[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]9[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Item 2[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Item 3[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Item 4[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]14[/TD]
[TD]7[/TD]
[TD]12[/TD]
[TD]11[/TD]
[TD]6[/TD]
[TD]0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Item 5[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Item 6[/TD]
[TD]2[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Item 7[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]Other[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]

How would I do a comparison of the following summations: B3:J3, B4:J4, B5:J5, etc and find the largest then tell which Item number that is? For example, Item 4 is the biggest here and that is what the formula should return.

Also, do the same thing consequentially for the vertical columns (which just uses the total row in theory) and which ever is the biggest return the color that corresponds. For example, Green in this case.

Both will be separate cell formulas (ie the vertical comparisons will have their own cell and the horizontal ones their own cell).

Sample Workbook: https://www.dropbox.com/s/8wispz7r6bl0178/Sample.xlsx?dl=0

Thanks :)
 
Last edited:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Seeing as how you already have a (helper) row for the column totals, why not just add another 1 for the row totals?
[Table="width:, class:grid"][tr][td] [/td][td]
A​
[/td][td]
B​
[/td][td]
C​
[/td][td]
D​
[/td][td]
E​
[/td][td]
F​
[/td][td]
G​
[/td][td]
H​
[/td][td]
I​
[/td][td]
J​
[/td][td]
K​
[/td][/tr]
[tr][td]
1​
[/td][td]Sizes:[/td][td]Red[/td][td]Blue[/td][td]Green[/td][td]Yellow[/td][td]Black[/td][td]White[/td][td]Purple[/td][td]Orange[/td][td]Brown[/td][td][/td][/tr]

[tr][td]
2​
[/td][td]Total[/td][td]5[/td][td]1[/td][td]16[/td][td]15[/td][td]21[/td][td]12[/td][td]7[/td][td]9[/td][td]1[/td][td][/td][/tr]

[tr][td]
3​
[/td][td]Item 1[/td][td]2[/td][td]0[/td][td]1[/td][td]8[/td][td]8[/td][td]1[/td][td]1[/td][td]9[/td][td]0[/td][td]
30​
[/td][/tr]

[tr][td]
4​
[/td][td]Item 2[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]1[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]
1​
[/td][/tr]

[tr][td]
5​
[/td][td]Item 3[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]
0​
[/td][/tr]

[tr][td]
6​
[/td][td]Item 4[/td][td]1[/td][td]1[/td][td]14[/td][td]7[/td][td]12[/td][td]11[/td][td]6[/td][td]0[/td][td]1[/td][td]
53​
[/td][/tr]

[tr][td]
7​
[/td][td]Item 5[/td][td]0[/td][td]0[/td][td]1[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]
1​
[/td][/tr]

[tr][td]
8​
[/td][td]Item 6[/td][td]2[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]
2​
[/td][/tr]

[tr][td]
9​
[/td][td]Item 7[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]
0​
[/td][/tr]

[tr][td]
10​
[/td][td]Other[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]0[/td][td]
0​
[/td][/tr]

[tr][td]
11​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td]
12​
[/td][td][/td][td]Black[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td]
13​
[/td][td][/td][td]Item 4[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]

B12=INDEX($B$1:$J$1,MATCH(LARGE($B$2:$J$2,1),$B$2:$J$2,0))
B13=INDEX($A$3:$A$10,MATCH(LARGE($K$3:$K$10,1),$K$3:$K$10,0))
 
Upvote 0
Thanks. I would add one, but the table I gave you is just a small fraction of the total table. The table keeps extending beyond the last color as the next set uses the same items and colors but different data results and my boss is OCD about the structure staying the same (yeah, he is one of those). Is there a way sum them up individually and then do the index match?
 
Upvote 0
So the totals in the headings is still OK?
Can you insert a column (uyou can hide it, if needed), and put the totals in there? The SUM() range can be as wide as you want it
 
Upvote 0
Yeah, heading totals are fine (he put them there), the side though he doesn't like, but I will see what I can do with hiding a column idea. Just in case, is there any other way to do it?
 
Upvote 0
[Table="width:, class:grid"][tr][td]Row\Col[/td][td]
A​
[/td][td]
B​
[/td][td]
C​
[/td][td]
D​
[/td][td]
E​
[/td][td]
F​
[/td][td]
G​
[/td][td]
H​
[/td][td]
I​
[/td][td]
J​
[/td][td]
K​
[/td][td]
L​
[/td][td]
M​
[/td][td]
N​
[/td][td]
O​
[/td][/tr]
[tr][td]
1​
[/td][td]Sizes:[/td][td]Red[/td][td]Blue[/td][td]Green[/td][td]Yellow[/td][td]Black[/td][td]White[/td][td]Purple[/td][td]Orange[/td][td]Brown[/td][td][/td][td][/td][td]max[/td][td][/td][td]max[/td][/tr]


[tr][td]
2​
[/td][td]Total[/td][td]
5
[/td][td]
1
[/td][td]
16
[/td][td]
15
[/td][td]
74
[/td][td]
12
[/td][td]
7
[/td][td]
9
[/td][td]
1
[/td][td][/td][td][/td][td]
74​
[/td][td][/td][td]
53​
[/td][/tr]


[tr][td]
3​
[/td][td]Item 1[/td][td]
2
[/td][td]
0
[/td][td]
1
[/td][td]
8
[/td][td]
8
[/td][td]
1
[/td][td]
1
[/td][td]
9
[/td][td]
0
[/td][td][/td][td][/td][td]count[/td][td][/td][td]count[/td][/tr]


[tr][td]
4​
[/td][td]Item 2[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
1
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td][/td][td][/td][td]
1​
[/td][td][/td][td]
2​
[/td][/tr]


[tr][td]
5​
[/td][td]Item 3[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td][/td][td][/td][td]color(s)[/td][td][/td][td]item(s)[/td][/tr]


[tr][td]
6​
[/td][td]Item 4[/td][td]
1
[/td][td]
1
[/td][td]
14
[/td][td]
7
[/td][td]
12
[/td][td]
11
[/td][td]
6
[/td][td]
0
[/td][td]
1
[/td][td][/td][td][/td][td]Black[/td][td][/td][td]Item 4[/td][/tr]


[tr][td]
7​
[/td][td]Item 5[/td][td]
0
[/td][td]
0
[/td][td]
1
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td][/td][td][/td][td][/td][td][/td][td]Other[/td][/tr]


[tr][td]
8​
[/td][td]Item 6[/td][td]
2
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]


[tr][td]
9​
[/td][td]Item 7[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]


[tr][td]
10​
[/td][td]Other[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
53
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td]
0
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


In M2 enter:
Rich (BB code):

=MAX(B2:J2)

In M4 enter:
Rich (BB code):

=COUNTIFS(B2:J2,M2)

In M6 control+shift+enter, not just enter, and copy down:
Rich (BB code):

=IF(ROWS($M$6:M6)<=$M$4,INDEX($B$1:$J$1,SMALL(IF($B$2:$J$2=$M$2,
    COLUMN($B$1:$J$1)-COLUMN($B$1)+1),ROWS($M$6:M6))),"")<strike></strike>

In O2 control+shift+enter, not just enter:
Rich (BB code):

=MAX(MMULT(B3:J10,TRANSPOSE(COLUMN(B3:J10)^0)))<strike></strike>

In O4 control+shift+enter, not just enter:
Rich (BB code):

=SUM(IF(MMULT(B3:J10,TRANSPOSE(COLUMN(B3:J10)^0))=O2,1))

In O6 control+shift+enter, not just enter, and copy down:
Rich (BB code):

=IF(ROWS($O$6:O6)<=$O$4,INDEX($A$3:$A$10,
    SMALL(IF(MMULT($B$3:$J$10,TRANSPOSE(COLUMN($B$3:$J$10)^0))=$O$2,
    ROW($A$3:$A$10)-ROW($A$3)+1),ROWS($O$6:O6))),"")<strike></strike>
 
Upvote 0

Impressive solution. I ended up doing the dirty "hide the totals column" method, but your method intrigues me because it handles various overlaps such as too items having the highest amount or colors. How does it handle data if all of it is zero? It would be a simple if statement to control it down the line somewhere, but I am just curious. Could you upload a sample sheet for me to test some data on?
 
Upvote 0
Impressive solution. I ended up doing the dirty "hide the totals column" method, but your method intrigues me because it handles various overlaps such as too items having the highest amount or colors. How does it handle data if all of it is zero? It would be a simple if statement to control it down the line somewhere, but I am just curious. Could you upload a sample sheet for me to test some data on?

You can rebuild the set up in your workbook.

If you are worried about empty data cells, you need a small modification of the formulas I already offered...

O2 >>

{=MAX(MMULT(IF(ISNUMBER(B3:J10),B3:J10,0),TRANSPOSE(COLUMN(B3:J10)^0)))}

O4 >>

{=SUM(IF(MMULT(IF(ISNUMBER(B3:J10),B3:J10,0),TRANSPOSE(COLUMN(B3:J10)^0))=O2,1))}

O6 >>

{=IF(ROWS($O$6:O6)<=$O$4,INDEX($A$3:$A$10,SMALL(IF(MMULT(IF(ISNUMBER($B$3:$J$10),$B$3:$J$10,0),TRANSPOSE(COLUMN($B$3:$J$10)^0))=$O$2,ROW($A$3:$A$10)-ROW($A$3)+1),ROWS($O$6:O6))),"")}
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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