Sortby with multiple entries and columns

osciva

New Member
Joined
Apr 26, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi,

Looking for help with a formula... I assume a combination of Sortby, Unique, Filter...? My scenariois similar to this: I want to output a unique, sorted and filtered list of the top selling fruits in Sweden, from a table similar to this

A (fruit)B (country)C (sold quantity)
AppleSweden10
AppleNorway5
AppleSweden4
PearSweden4
PearSweden2
PearNorway8
OrangeSweden5
OrangeSweden25
BananaNorway10

I.e. the output I want to have from my formula is:
Orange
Apple
Pear

Thanks.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,365
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Assuming you want to sort based on the aggregated totals, a pivot table would seem a simple solution.
 

osciva

New Member
Joined
Apr 26, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Assuming you want to sort based on the aggregated totals, a pivot table would seem a simple solution.
Thanks, and correct, I want to sort based on the aggregated totalts. However, a pivot table isn't suitable since this will be a part of an excel dashboard with specific layout.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,365
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
It's still not clear how a pivot table wouldn't suit, but I'd at least use one as a summary, then your dashboard can simply source the list from that if need be.
 

kweaver

Well-known Member
Joined
May 8, 2018
Messages
2,107
Office Version
  1. 365
  2. 2010

ADVERTISEMENT

Not necessarily a solution to your problem (which I found interesting). I played around with it, first by sorting the original data in columns A-C per the example below.

Book2
ABCDEFGHIJ
1A (fruit)B (country)C (sold quantity)X-Country
2PearNorway25MangoMangoMangoX-Country35
3BananaNorway10PearPearPearX-Country25
4AppleNorway5 RaspberryMangoX-Country10
5OrangeSweden25RaspberryRaspberryX-Country5
6AppleSweden10 
7OrangeSweden5 
8AppleSweden4 
9PearSweden4 
10PearSweden2 
11MangoX-Country35 
12PearX-Country25 
13MangoX-Country10 
14RaspberryX-Country5 
Sheet3
Cell Formulas
RangeFormula
F2:F4F2=UNIQUE(FILTER(E2:E14,E2:E14<>""))
H2:J5H2=FILTER(A2:C14,E1=B2:B14)
E2:E14E2=(IF(COUNTIF(H$2:H2,H2)=1,H2,""))
Dynamic array formulas.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,638
Office Version
  1. 365
Platform
  1. Windows
Another option if you have the LET function
+Fluff 1.xlsm
ABCDEF
1A (fruit)B (country)C (sold quantity)Sweden
2AppleSweden10Orange
3AppleNorway5Apple
4AppleSweden4Pear
5PearSweden4
6PearSweden2
7PearNorway8
8OrangeSweden5
9OrangeSweden25
10BananaNorway10
11
Master
Cell Formulas
RangeFormula
F2:F4F2=LET(uni,UNIQUE(A2:A10),sm,SUMIFS(C2:C10,B2:B10,F1,A2:A10,uni),SORTBY(FILTER(uni,sm>0),FILTER(sm,sm>0),-1))
Dynamic array formulas.
 

osciva

New Member
Joined
Apr 26, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Another option if you have the LET function
+Fluff 1.xlsm
ABCDEF
1A (fruit)B (country)C (sold quantity)Sweden
2AppleSweden10Orange
3AppleNorway5Apple
4AppleSweden4Pear
5PearSweden4
6PearSweden2
7PearNorway8
8OrangeSweden5
9OrangeSweden25
10BananaNorway10
11
Master
Cell Formulas
RangeFormula
F2:F4F2=LET(uni,UNIQUE(A2:A10),sm,SUMIFS(C2:C10,B2:B10,F1,A2:A10,uni),SORTBY(FILTER(uni,sm>0),FILTER(sm,sm>0),-1))
Dynamic array formulas.
Thanks, that worked perfectly!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,638
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Forum statistics

Threads
1,141,817
Messages
5,708,760
Members
421,588
Latest member
Wawie

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
Top