Return Name of Category with Max Sum

gamerosko

Board Regular
Joined
Jan 22, 2008
Messages
105
Hi guys,
can you help with formula? Below is a list of Customer transactions & their values within Industries. Formula should Sum Up Prices in Industries for each Cust ID and return name of Max Sum Industry into Leading Industry.

Cust IDIndustryPriceLeading Industry
5Restaurants100
1Airlines2300
3Airlines3230
5Lodging800
2Telco50
1Telco120
5Restaurants750

<tbody>
</tbody>

Thus for Cust ID 5 rows this should be Restaurants, for Cust ID 1 Airlines etc... If there are more Leading Industries with same values, return any of the leading one.

Thanks much for help. BR, Gamca
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Simplest way would be to create a totals table;
Restaurants
=sumif([Industry],[Ref],[Price]
=RANK([SUMIF],[SUMIF RANGE],0)
Airlines
Lodging
Telco

<tbody>
</tbody>

Then you can either INDEX MATCH or VLOOKUP the Rank into Leading Industry?
 
Last edited:
Upvote 0
In D2:

=INDEX($B$2:$B$8,MATCH(A2&"|"&MAX(IF($A$2:$A$8=A2,$C$2:$C$8)),$A$2:$A$8&"|"&$C$2:$C$8,0))
confirmed with Control+Shift+Enter.

Also, I got Lodging for Cust ID 5 (800). Let me know if this works for you.
 
Upvote 0
In D2:

=INDEX($B$2:$B$8,MATCH(A2&"|"&MAX(IF($A$2:$A$8=A2,$C$2:$C$8)),$A$2:$A$8&"|"&$C$2:$C$8,0))
confirmed with Control+Shift+Enter.

Also, I got Lodging for Cust ID 5 (800). Let me know if this works for you.

Hello Eric, thanks for help - actually Cust ID 5 showing Lodging is a mistake - it should show Restaurants (850 in totals for Cust 5) - so that is the only difference.. I am not looking for max line, but for max subtotal.
 
Upvote 0
I couldn't see how to do it without using a helper column. Someone else may have more luck:


Book1
ABCDE
1Customer IDIndustryPriceLeading IndustryHelper
25Restaurants100Restaurants850
31Airlines2300Airlines2300
43Airlines3230Airlines3230
55Lodging800Restaurants800
62Telco50Telco50
71Telco120Airlines120
85Restaurants750Restaurants850
Sheet2
Cell Formulas
RangeFormula
E2=SUMIFS($C$2:$C$8,$A$2:$A$8,$A2,$B$2:$B$8,$B2)
D2{=INDEX($B$2:$B$8,MATCH(MAX(IF($A$2:$A$8=$A2,$E$2:$E$8)),$E$2:$E$8,0))}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Upvote 0
Sorry, I missed the subtotal part. We can still do it with a single formula, similar in principle to what WBD came up with:

Excel 2012
ABCD
1Cust IDIndustryPriceLeading Industry
25Restaurants100Restaurants
31Airlines2300Airlines
43Airlines3230Airlines
55Lodging800Restaurants
62Telco50Telco
71Telco120Airlines
85Restaurants750Restaurants

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
D2{=INDEX($B$2:$B$8,MATCH(MAX(SUMIFS($C$2:$C$8,$A$2:$A$8,A2,$B$2:$B$8,$B$2:$B$8)),SUMIFS($C$2:$C$8,$A$2:$A$8,A2,$B$2:$B$8,$B$2:$B$8),0))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
Thanks Eric - working nicely.. I thought it will be something nasty like this.. ! :)
Thanks as well to others - nice ideas !

BR, gamerosko
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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