Formula for 10 top by department, but only showing results greater than 0

DanielJeff

New Member
Joined
Apr 26, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Afternoon,

I've been working on a top 10 list so that we can see the top 10 sales by department. I've written 3 formulas to display what i need, but my issue is that they return entries with 0 sales and i dont need to see these.
My knowledge of more complex formulas is quite basic and i've pieced together my formulas from bits i've found on various websites.

Below is a table containing an example of the type of data i've used and underneath that is my table that my formulas produce along with the formulas used for each of the 3 columns. As you're be able to see I've got it show that the formula reads A31 (cell i type the department code in) I need the top 10 for, but it then displays any 0 sales for that code in my table.
I need to be able to change the code and it list anyone with sales in that code. I then need to factor in A28 so that i can change this number from between 1-10 and it display those result, for example if i want to see code FP, but only the top 3 people or 5 people in that code.

Hopefully i've explained that clearly

NameCodeDepartmentSalesTotal Royalty
Kiana CollinsFPAgrii
1.000​
£187.00​
Miles FrederickFPWarehouse
2.000​
£0.00​
Jaycee BestFPFront Office
3.000​
£0.00​
Adeline HarringtonFPRemote
0.000​
£0.00​
Mary JamesFPMachine
0.000​
£1,500.00​
Carolina ToddLSAgrii
1.000​
£0.00​
Alexa FosterLSWarehouse
2.000​
£0.00​
Kayden HopkinsLSFront Office
3.000​
£0.00​
Gabriela FlemingLSRemote
0.000​
£0.00​
Andrea LarsonLSMachine
0.000​
£230.00​
Rafael ThomasSBAgrii
0.000​
£0.00​
Elizabeth MillerSBWarehouse
1.000​
£0.00​
Russell WardSBFront Office
2.000​
£0.00​
Ariana BeilSBRemote
3.000​
£0.00​
Roselyn TurnerSBMachine
0.000​
£0.00​
Roger BishopSWAgrii
1.000​
£0.00​
Sydney GalvanSWWarehouse
2.000​
£0.00​
Kingsley BruceSWFront Office
3.000​
£0.00​
Teresa MaynardSWRemote
0.000​
£0.00​
Landry StokesSWMachine
0.000​
£0.00​
Miranda ReillyWWAgrii
1.000​
£0.00​
Brooklynn MorganWWWarehouse
2.000​
£0.00​
Harvey MontesWWFront Office
0.000​
£0.00​
=INDEX($A$2:$A$24,SMALL(IF(($D$2:$D$24=D27)*($B$2:$B$24=$A$31),ROW($D$2:$D$24)-ROW($D$1)),COUNTIF(D27:$D$27,D27)))=FILTER(Totals[Department],Totals[Name]=B27,"")=LARGE(IF($B$2:$B$24=$A$31,$D$2:$D$24),ROW(B27)-ROW(B$26))
Top SalesJaycee BestFront Office
3​
10Miles FrederickWarehouse
2​
Kiana CollinsAgrii
1​
DepartmentAdeline HarringtonRemote
0​
FPMary JamesMachine
0​
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
How about
Fluff.xlsm
ABCDE
1NameCodeDepartmentSalesTotal Royalty
2Kiana CollinsFPAgrii1187
3Miles FrederickFPWarehouse20
4Jaycee BestFPFront Office30
5Adeline HarringtonFPRemote00
6Mary JamesFPMachine01,500.00
7Carolina ToddLSAgrii10
8Alexa FosterLSWarehouse20
9Kayden HopkinsLSFront Office30
10Gabriela FlemingLSRemote00
11Andrea LarsonLSMachine0230
12Rafael ThomasSBAgrii00
13Elizabeth MillerSBWarehouse10
14Russell WardSBFront Office20
15Ariana BeilSBRemote30
16Roselyn TurnerSBMachine00
17Roger BishopSWAgrii10
18Sydney GalvanSWWarehouse20
19Kingsley BruceSWFront Office30
20Teresa MaynardSWRemote00
21Landry StokesSWMachine00
22Miranda ReillyWWAgrii10
23Brooklynn MorganWWWarehouse20
24Harvey MontesWWFront Office0£0.00
25
26
27Top SalesJaycee BestFront Office3
2810Miles FrederickWarehouse2
29Kiana CollinsAgrii1
30Department
31FP
Sheet5
Cell Formulas
RangeFormula
B27:D29B27=TAKE(SORT(FILTER(CHOOSECOLS(Totals,1,3,4),(Totals[Code]=A31)*(Totals[Sales]>0)),3,-1),A28)
Dynamic array formulas.
 
Upvote 0
Solution
How about
Fluff.xlsm
ABCDE
1NameCodeDepartmentSalesTotal Royalty
2Kiana CollinsFPAgrii1187
3Miles FrederickFPWarehouse20
4Jaycee BestFPFront Office30
5Adeline HarringtonFPRemote00
6Mary JamesFPMachine01,500.00
7Carolina ToddLSAgrii10
8Alexa FosterLSWarehouse20
9Kayden HopkinsLSFront Office30
10Gabriela FlemingLSRemote00
11Andrea LarsonLSMachine0230
12Rafael ThomasSBAgrii00
13Elizabeth MillerSBWarehouse10
14Russell WardSBFront Office20
15Ariana BeilSBRemote30
16Roselyn TurnerSBMachine00
17Roger BishopSWAgrii10
18Sydney GalvanSWWarehouse20
19Kingsley BruceSWFront Office30
20Teresa MaynardSWRemote00
21Landry StokesSWMachine00
22Miranda ReillyWWAgrii10
23Brooklynn MorganWWWarehouse20
24Harvey MontesWWFront Office0£0.00
25
26
27Top SalesJaycee BestFront Office3
2810Miles FrederickWarehouse2
29Kiana CollinsAgrii1
30Department
31FP
Sheet5
Cell Formulas
RangeFormula
B27=TAKE(SORT(FILTER(CHOOSECOLS(Totals,1,3,4),(Totals[Code]=A31)*(Totals[Sales]>0)),3,-1),A28)
Dynamic array formulas.
D]B27:D29[/XD]

Fluff

If only I had a bit of your knowledge, i might not actually mind these excel tasks i keep getting sent to do.

2nd time you've helped me today and each time its worked a treated.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,894
Messages
6,181,618
Members
453,057
Latest member
LE102024

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