Creating a List in Descending Order with Criteria From Data Dump

KimboSlice

New Member
Joined
Feb 1, 2017
Messages
1
Hi all,

Long time lurker, first time poster. I have the following table:

ABCDEF
1ProductCategorySalesFruit
2CarrotVegetable10
3SquashVegetable40
4PineappleFruit90
5BlueberriesFruit20CorrectApple
6OnionVegetable60AnswerPineapple
7AppleFruit100Orange
8BananaFruit30
9LettuceVegetable80
10PeasVegetable70
11OrangeFruit50

<tbody>
</tbody>


In cells F1, F2, and F3, I want to create a list of the 3 Products with the most sales, from most to least sales, that also match the criteria in cell E1, "Fruit". So in this instance, I would see F1 = Apple, F2 = Pineapple, and F3 = Orange.

The data dump is "redumped" quite frequently, so I would prefer to not use helper columns.

My apologies in advance if this formula question has already been discussed. I've been able to find solutions to parts of it on the internet, but not one that puts it all together.

Any help is greatly appreciated!

Thanks!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Welcome to the Forum.

May I suggest that you watch a video on the ExcelIsFun channel on youtube? It think it does exactly what you want using formulas. It considers ties and duplicates, so it is robust enough. If it suits your purposes, try out the techniques - you can even download the file associated with the video and conduct experiments.

Let us know.

https://www.youtube.com/watch?v=rKDI-kdBsjY
 
Last edited:
Upvote 0
That formula works as long as there are no ties within the Top 3. Let me know if you need a formula that will work even with ties, I have done it before.

I used named ranges for easier reading.

A
B
C
D
E
F
1
ProductCategorySalesFruit{=INDEX( Products, MATCH( LARGE((Categories=$E$1)*Sales,ROW()-ROW($E$1)+1), Sales, 0 ) )}
2
CarrotVegetable
10​
{=INDEX( Products, MATCH( LARGE((Categories=$E$1)*Sales,ROW()-ROW($E$1)+1), Sales, 0 ) )}
3
SquashVegetable
40​
{=INDEX( Products, MATCH( LARGE((Categories=$E$1)*Sales,ROW()-ROW($E$1)+1), Sales, 0 ) )}
4
PineappleFruit
90​
5
BlueberriesFruit
20​
CorrectApple
6
OnionVegetable
60​
AnswerPineapple
7
AppleFruit
100​
Orange
8
BananaFruit
30​
9
LettuceVegetable
80​
10
PeasVegetable
70​
11
OrangeFruit
50​

<tbody>
</tbody>

Values
ABCDEF
1ProductCategorySalesFruitApple
2CarrotVegetable 10 Pineapple
3SquashVegetable 40 Orange
4PineappleFruit 90
5BlueberriesFruit 20 CorrectApple
6OnionVegetable 60 AnswerPineapple
7AppleFruit 100 Orange
8BananaFruit 30
9LettuceVegetable 80
10PeasVegetable 70
11OrangeFruit 50

<colgroup><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>


Array Formulas
CellFormula
F1{=INDEX( Products, MATCH( LARGE((Categories=$E$1)*Sales,ROW()-ROW($E$1)+1), Sales, 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>

Workbook Defined Names
NameRefers To
Categories=Hoja4!$B$2:$B$11
Products=Hoja4!$A$2:$A$11
Sales=Hoja4!$C$2:$C$11

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Row\Col
A​
B​
C​
D​
1​
ProductCategorySalesFruit
2​
CarrotVegetable
10
3
3​
SquashVegetable
40
Apple
4​
PineappleFruit
90
Pineapple
5​
BlueberriesFruit
20
Orange
6​
OnionVegetable
60
7​
AppleFruit
100
8​
BananaFruit
30
9​
LettuceVegetable
80
10​
PeasVegetable
70
11​
OrangeFruit
50
12​

In D2 just enter:

=MIN(3,COUNTIFS($B$2:$B$11,D$1))

In D3 control+shift+enter, not just enter, and copy down:

=IF(ROWS(D$3:D3)<=D$2,INDEX($A$2:$A$11,SMALL(IF(C$2:C$11=LARGE(IF($B$2:$B$11=$D$1,C$2:C$11),ROWS($D$3:D3)),ROW(C$2:C$11)-ROW(C$2)+1),
SUM(IF(LARGE(IF($B$2:$B$11=$D$1,C$2:C$11),ROW(C$2:C2)-ROW($C$2)+1)=LARGE(IF($B$2:$B$11=$D$1,C$2:C$11),ROWS(D$3:D3)),1)))),"")

Note that the set up does not aggregate multiple occurrences of a product if multiple occurrence is possible.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,577
Members
449,039
Latest member
Arbind kumar

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