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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Assuming you want to sort based on the aggregated totals, a pivot table would seem a simple solution.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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