How to get a dynamic 'most common value'??

krazykaj

Board Regular
Joined
Jul 20, 2005
Messages
143
Hi Guys,

I am stuck…
It seems really easy to do when I look at it, but telling excel to do what I can clearly see is not so fun!!

Basically I have a list of clients (this list changes all the time so the formula needs to be dynamic)
Against each client is a product that they own. What I want to do is quickly find out what product each client owns the most of.


Example:
(the following in cells A1:C23


Client-Product-MainProd
John-apple-?
John-apple-?
John-beans-?
John-apple-?
John-beans-?
Frank-tomato-?
Frank-tomato-?
Frank-squash-?
Frank-squash-?
Frank-tomato-?
Tom-egg-?
Tom-egg-?
Tom-egg-?
Tom-egg-?
Jane-carrots-?
Jane-mango-?
Jane-mango-?
Jane-mango-?
Jane-carrots-?
Jane-mango-?
Jane-carrots-?
Jane-mango-?


So against each Client ID is a product. You can see that in all cases one product will be more common than the rest. So for John it is apples. Sometimes it is the only product a client has. Like for Tom, he only has eggs/

How do I count for each client individually their holdings in each product they own to then get a result of the product with the highest count... ???

So the result in the MajorProdResult should be:


Client-Product-MainProd
John-apple-apple
John-apple-apple
John-beans-apple
John-apple-apple
John-beans-apple
Frank-tomato-tomato
Frank-tomato-tomato
Frank-squash-tomato
Frank-squash-tomato
Frank-tomato-tomato
Tom-egg-egg
Tom-egg-egg
Tom-egg-egg
Tom-egg-egg
Jane-carrots-mango
Jane-mango-mango
Jane-mango-mango
Jane-mango-mango
Jane-carrots-mango
Jane-mango-mango
Jane-carrots-mango
Jane-mango-mango



Hope that makes sense . . .
Is this possible via Formula??
I can probably do it easily via VBA ... but i would like not to use any macro in this instance....

thank you for any time and help you may be able to provide!

Cheers
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi,

Maybe this Array-formula in C2

=INDEX($B$2:$B$23,MIN(IF(IF($A$2:$A$23=A2,COUNTIF($B$2:$B$23,$B$2:$B$23))=MAX(IF($A$2:$A$23=A2,COUNTIF($B$2:$B$23,$B$2:$B$23))),ROW($A$2:$A$23)-ROW($A$2)+1)))

confirmed with Ctrl+Shift+Enter
(hold down both Ctrl and Shift keys and hit Enter)

copy down

HTH

M.
 
Upvote 0
Hi friend:)

Hope to add some help:)
Excel Workbook
ABC
1ClientProductMainProduct
2JohnappleJohn-apple-apple
3JohnappleJohn-apple-apple
4JohnbeansJohn-beans-apple
5JohnappleJohn-apple-apple
6JohnbeansJohn-beans-apple
7FranktomatoFrank-tomato-tomato
8FranktomatoFrank-tomato-tomato
9FranksquashFrank-squash-tomato
10FranksquashFrank-squash-tomato
11FranktomatoFrank-tomato-tomato
12TomeggTom-egg-egg
13TomeggTom-egg-egg
14TomeggTom-egg-egg
15TomeggTom-egg-egg
16JanecarrotsJane-carrots-mango
17JanemangoJane-mango-mango
18JanemangoJane-mango-mango
19JanemangoJane-mango-mango
20JanecarrotsJane-carrots-mango
21JanemangoJane-mango-mango
22JanecarrotsJane-carrots-mango
23JanemangoJane-mango-mango
Sheet31
Excel 2010
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Hope your feedback:)
 
Upvote 0
Excellent!!!!

Still trying to figure out what exactly that formula does ... but it works! :)

Thank you both for you help!!!
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

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