Filter with Sort and multiple criteria.

jd yort

Board Regular
Joined
Aug 7, 2006
Messages
82
Hi everyone,

I have a minor hurdle that I have been slamming my hand in the desk drawer over and hoping an Excel Yoda can assist....
I want to Filter the below table and return the records based on the number sold for a region.

I can get it to work without restricting the region (formula in W3), however when I want to factor in the Region I can't quite get it to work (formula in W13).
I thought I would need to do it with an INDEX but maybe that is where I am going wrong and overly complicating it.

Any idea's legends?

Thanks

JD

=INDEX(SORT(FILTER($H$5:$K$18,($K$5:$K$18>=LARGE($K$5:$K$18,$K$2))*($J$5:$J$18=$I$2)),4,-1),,1)

1742354001467.png
 
Hello, would this work for you (are you using Excel 365?):

Excel Formula:
=SORT(FILTER(H5:K18,(J5:J18=I2)*((COUNTIFS(J5:J18,J5:J18,K5:K18,">"&K5:K18)+1)<=K2)),4,-1)
 
Upvote 0
Solution
If you are happy to show only five results, a shorter alternative would be: =TAKE(SORT(FILTER(H5:K18,J5:J18=I2),4,-1),K2)

If there are ties, @hagia_sofia's formula will include the tied values, and hence may show more than five results, which I think is the better outcome.
 
Upvote 0
Hello, would this work for you (are you using Excel 365?):

Excel Formula:
=SORT(FILTER(H5:K18,(J5:J18=I2)*((COUNTIFS(J5:J18,J5:J18,K5:K18,">"&K5:K18)+1)<=K2)),4,-1)
I tried this and it #CALC! errors. This is on office 365

Proving Grounds.xlsx
HIJKLMNOPQ
2Region:NorthernTop:5
3
4CodeBusinessRegionSoldA1242Secret ValleyCentral222
5A1234Golden CityEastern37A1241Rocky MountainCentral139
6A1235Beach RiverEastern24A1240Lake ViewCentral139
7A1236Green FieldsNothern178A1236Green FieldsNothern178
8A1237Shotgun ValleyCentral49A1245EdinsboroughCentral178
9A1238MudsvilleNothern24A1244Central CityCentral139
10A1239SmithfieldCentral67
11A1240Lake ViewCentral139
12A1241Rocky MountainCentral139
13A1242Secret ValleyCentral222
14A1243Yabby CreekNothern49#CALC!
15A1244Central CityCentral139
16A1245EdinsboroughCentral178
17A1246Summer BayCentral24
18A1247Yabbie CreekEastern37
Filter&Sort
Cell Formulas
RangeFormula
N4:Q9N4=SORT(FILTER(Table1, Table1[Sold]>=LARGE(Table1[Sold], K2)), 2, -1)
N14N14=SORT(FILTER(H5:K18,(J5:J18=I2)*((COUNTIFS(J5:J18,J5:J18,K5:K18,">"&K5:K18)+1)<=K2)),4,-1)
Dynamic array formulas.
 
Upvote 0
Hello, would this work for you (are you using Excel 365?):

Excel Formula:
=SORT(FILTER(H5:K18,(J5:J18=I2)*((COUNTIFS(J5:J18,J5:J18,K5:K18,">"&K5:K18)+1)<=K2)),4,-1)

This is perfect. Exactly what I was after. Thank you so much and everyone else for taking the time to reply.
 
Upvote 0
Actually one follow up question... if I just wanted to only return the first column, ie the code only rather than the entire table.
What would I need to change?

=SORT(FILTER(H5:K18,(J5:J18=I2)*((COUNTIFS(J5:J18,J5:J18,K5:K18,">"&K5:K18)+1)<=K2)),4,-1)

I know it is not as simple at moving it from H5:K18 to H5:H18 in the Filter.
 
Upvote 0
Many thanks for the feedback. As far as your question is concerned, actually it is just what you described.
 
Upvote 0
I was hoping that it was that simple but something is a miss.

=SORT(FILTER(H5:H18,(J5:J18=I2)*((COUNTIFS(J5:J18,J5:J18,K5:K18,">"&K5:K18)+1)<=K2)),4,-1)


1742425473676.png
 
Upvote 0
Sorry, I forgot that the original formula was sorting the result by the 4th column - change the 4 at the end to 1 and it should work (you might also wanna check if -1 is the right order for you).
 
Upvote 0

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