DOUBLE FILTER function to return ONLY records with most recent date

elcalvo

New Member
Joined
Dec 15, 2023
Messages
12
Office Version
  1. 365
Platform
  1. Windows
I got valuable input from @Fluff and @RoryA on a FILTER function to return ONLY records with most recent date



  • I'm using Office 365
  • I have a defined table named Table1 with headers and its data below. I added a helper column in M (Include Partner) with the formula: =XLOOKUP([@Partner],check!$A$2#,check!$B$2:$B$4) which checks if the checkbox for a certain partner is checked (TRUE) or unchecked (FALSE)
  • In another sheet (called “check”), I have made a filter section for Partners in A2: =SORT(UNIQUE(Table1[Partner])) with inserted checkboxes (insert – cell controls) which are TRUE or FALSE
  • I want a formula that filters on "Meeting" in column F (Type) so it returns only rows with "Meeting" and only shows the most recent date as per column G (Last) AND that filters on the ticked boxes from the Partners filter section (see previous bullet)


I have tried to change RoryA's formula which was:

=LET(

z, exampledata,

a, FILTER(z, INDEX(z, , 6) = "Meeting"),

uc, UNIQUE(INDEX(a,0,4)),

b, SORT(SORT(a, 4, ), 7,-1 ),

c,INDEX(b,0,4),

result,REDUCE("",uc,LAMBDA(a,i,VSTACK(a,TAKE(FILTER(b,c=i),1)))),

DROP(result,1)

)



And got as far as:

=VSTACK(

exampledata[#Headers],

LET(

z, exampledata,

a, SORT(SORT(FILTER(z, (INDEX(z, , 6) = "Meeting") * exampledata[Include Partner]), 4, 1), 7, -1),

uc, UNIQUE(INDEX(a, 0, 4)),

c, INDEX(a, 0, 4),

result, REDUCE("", uc, LAMBDA(a,i, VSTACK(a, TAKE(FILTER(a, c = i), 1)))),

DROP(result, 1)

)

)



Which returns a value error.

I’d appreciate if anyone can shine a light on this and maybe explain what I am doing wrong



To Do.xlsm
ABCDEFGHIJKLM
2#PartnerClassCompanyProductTypeLastPrioXNextDueAction/notesInclude Partner
31Partner 1OtherCompany AOtherMeeting31/01/20231TRUE02/02/2023xNotes 1TRUE
44Partner 1OtherCompany AOtherMeeting22/03/20231TRUE06/08/2023Notes 2TRUE
534Partner 2OtherCompany DOtherMeeting09/07/20231TRUE09/07/2023xNotes 3FALSE
633Partner 3OtherCompany EOtherAction09/07/20231TRUE09/07/2023Notes 4FALSE
735Partner 2OtherCompany FOtherMeeting11/07/20231TRUE13/07/2023Notes 5FALSE
842Partner 2OtherCompany DOtherMeeting23/07/20231TRUE25/07/2023xNotes 6FALSE
946Partner 3OtherCompany GOtherMeeting04/08/20231TRUE04/08/2023Notes 7FALSE
1047Partner 1OtherCompany AOtherAction04/08/20231TRUE04/08/2023Notes 8TRUE
1148Partner 1OtherCompany BOtherAction06/08/20231TRUE06/08/2023xNotes 9TRUE
12206Partner 1OtherCompany COtherMeeting01/12/20231TRUE24/03/2023Notes 10TRUE
Sheet10
Cell Formulas
RangeFormula
M3:M12M3=XLOOKUP([@Partner],check!$A$2#,check!$B$2:$B$4)




To Do.xlsm
AB
1Partner
2Partner 1
3Partner 2
4Partner 3
check
Cell Formulas
RangeFormula
A2:A4A2=SORT(UNIQUE(Table1[Partner]))
Dynamic array formulas.


To Do.xlsm
ABCDEFGHIJKL
1Partner
2Partner 1
3Partner 2
4Partner 3
5
6
7#PartnerClassCompanyProductTypeLastPrioXNextDueAction/notes
81Partner 1OtherCompany AOtherMeeting31/01/20231TRUE02/02/2023xNotes 1
9206Partner 1OtherCompany COtherMeeting01/12/20231TRUE24/03/2023Notes 10
104Partner 1OtherCompany AOtherMeeting22/03/20231TRUE06/08/2023Notes 2
check
Cell Formulas
RangeFormula
A2:A4A2=SORT(UNIQUE(Table1[Partner]))
Dynamic array formulas.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Assuming your table is actually called exampledata, not Table1, then I think this works:

Excel Formula:
=LET(
a, FILTER(exampledata,(exampledata[Type] = "Meeting")*(exampledata[Include Partner])),
uc, UNIQUE(INDEX(a,0,4)),
b, SORT(SORT(a, 4, ), 7,-1 ),
c,INDEX(b,0,4),
result,REDUCE(exampledata[#Headers],uc,LAMBDA(a,i,VSTACK(a,TAKE(FILTER(b,c=i),1)))),
result
)
 
Upvote 0
Solution
Assuming your table is actually called exampledata, not Table1, then I think this works:

Excel Formula:
=LET(
a, FILTER(exampledata,(exampledata[Type] = "Meeting")*(exampledata[Include Partner])),
uc, UNIQUE(INDEX(a,0,4)),
b, SORT(SORT(a, 4, ), 7,-1 ),
c,INDEX(b,0,4),
result,REDUCE(exampledata[#Headers],uc,LAMBDA(a,i,VSTACK(a,TAKE(FILTER(b,c=i),1)))),
result
)
thanks RoryA, this works ! I see now I kept including to VSTACKs ... and true, the table name was wrong

thanks a million
 
Upvote 0

Forum statistics

Threads
1,216,503
Messages
6,131,020
Members
449,615
Latest member
Nic0la

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