Intuitively I'd expected to combine FILTER, SORT and UNIQUE but I can't get them to do what I want.

IfAllElseFails

New Member
Joined
Jan 12, 2024
Messages
8
Office Version
  1. 365
Platform
  1. Windows
I want a SINGLE formula to return a SINGLE value from a table:
1) matching, in one column, a specified item
2) also, matching, in a second column, the highest date which is lower than a specified date

I can only manage it in 2 steps

I'm still getting to grips with functions which return multiple results

Help much appreciated
(sorry can't use the addin to upload a mini sheet - locked down corporate excel install)
 

Attachments

  • MR Excel Query 20240112FILTERSORTUNIQUE.PNG
    MR Excel Query 20240112FILTERSORTUNIQUE.PNG
    61.8 KB · Views: 12

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Maybe this:

Book1
ABCDEFGHIJ
1Item IDDate EffectiveGuidance
245.029/23/2023Approve if risk category is low or medium
345.0212/12/2022Request further info
445.021/11/2023Request further info and refer to Subject Matter ExpertFor Item ID45.02
545.027/14/2023Approve if risk category is lowOn Date3/15/2023
665.019/23/2023Approve if risk category is low or mediumThe Guidance in effect was
765.011/11/2023Request further info
865.017/14/2023Approve if risk category is low1/11/2023Request further info and refer to Subject Matter Expert
965.011/1/2024Approve if risk category is not critical
1019.129/23/2023Approve if risk category is low or medium
1119.121/11/2023Request further info
Sheet2
Cell Formulas
RangeFormula
I8:J8I8=CHOOSEROWS(SORT(FILTER(B:C,((A:A=J4)*(B:B<=J5))),1,-1),1)
Dynamic array formulas.
 
Upvote 0
How about?:

Book1
ABCDEFGHIJ
1Item IDDate EffectiveGuidance
245.0223/09/2023AItem ID45.02
345.0212/12/2023BOn Date15/03/2023
445.0210/01/2023THIS
545.0214/07/2023DResultTHIS
665.0123/09/2023AA
765.0112/12/2023BB
865.0110/01/2023CC
965.0114/07/2023DD
Sheet2
Cell Formulas
RangeFormula
J5J5=FILTER(C:C,(A:A=$J$2)*(B:B=MAX(IFERROR(B:B*(B:B<=$J$3)*(A:A=$J$2),0))))
 
Upvote 0
Hi & welcome to MrExcel.
How about
Excel Formula:
=TAKE(SORT(FILTER(B2:B1000,(A2:A1000=J4)*(B2:B1000<=J5)),1,-1),1,-1)
It's always best to avoid using whole column references in array formulae.
 
Upvote 1
MrExcelPlayground20 (version 1).xlsb
ABCDE
1ItemDateGuidance
245.029/23/2023Thing1Item45.02
345.0212/12/2022Thing2Date3/23/2023
445.021/11/2023Thing3
545.027/14/2023Thing4Thing3
665.019/23/2023Thing5
765.011/11/2023Thing6
865.017/14/2023Thing7
965.011/1/2024Thing8
1019.129/23/2023Thing9
1119.121/11/2023Thing10
Sheet24
Cell Formulas
RangeFormula
E5E5=INDEX(CHOOSECOLS(SORT(FILTER(B2:C11,A2:A11=E2),1),2),MATCH(E3,CHOOSECOLS(SORT(FILTER(B2:C11,A2:A11=E2),1),1),1))
 
Upvote 1
Thanks, that nearly worked - it returns both the date and the guidance.
But following your example and wrapping it with CHOOSECOLS does the trick!
 
Upvote 0
Thanks, that nearly worked - it returns both the date and the guidance.
But following your example and wrapping it with CHOOSECOLS does the trick!
In that case, you should use Fluff's suggestion in post #4. The TAKE does the same as both CHOOSEROWS and CHOOSECOLS combined.
 
Upvote 1
I thought you wanted only the text in column C. Formula in post 3 does that.
 
Upvote 0
Taking @Fluff 's suggestion into account, not to use whole columns:

Book1
ABCDEFGHIJ
1Item IDDate EffectiveGuidance
245.0223/09/2023AItem ID45.02
345.0212/12/2023BOn Date15/03/2023
445.0210/01/2023THIS
545.0214/07/2023DResultTHIS
665.0123/09/2023AA
765.0112/12/2023BB
865.0110/01/2023CC
965.0114/07/2023DD
Sheet2
Cell Formulas
RangeFormula
J5J5=FILTER(C1:C1000,(A1:A1000=$J$2)*(B1:B1000=MAX(IFERROR(B1:B1000*(B1:B1000<=$J$3)*(A1:A1000=$J$2),0))))
 
Upvote 1

Forum statistics

Threads
1,215,069
Messages
6,122,958
Members
449,096
Latest member
Anshu121

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