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
 
Alternatively, if you want to use the same LARGE construct as your original formula, try doing it in 2 steps and filter by region first. For example:
Excel Formula:
=LET(
   a, FILTER(H5:K18,J5:J18=I2),
   v, TAKE(a,,-1),
   SORT(FILTER(a,v>=LARGE(v,MIN(K2,ROWS(v)))),4,-1)
)

Also, use TAKE, INDEX or CHOOSECOLS to return the first column only:
Excel Formula:
=LET(
   a, FILTER(H5:K18,J5:J18=I2),
   v, TAKE(a,,-1),
   TAKE(SORT(FILTER(a,v>=LARGE(v,MIN(K2,ROWS(v)))),4,-1),,1)
)

Change the [sort_index] and/or [sort_order] as desired. Cheers!
 
Upvote 0
I have never used either LET or TAKE before. Works perfectly too. I will need to pull those formulas apart and understand them.
Added these also to my book of knowledge :)
 
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