You can achieve it by ranking by Date column within the same group, where the group is represented by the rows with the same primary key. In your case a combination of the following columns: CustomerName, ZipCode, and DOB. You can use the following formula in cell A6
:
=LET(in, A2:F4,pks, INDEX(in,,3)&"_"&INDEX(in,,4)&"_"&INDEX(in,,5),
dates, INDEX(in,,2), rnk, MAP(pks, dates,LAMBDA(pk,d,
SUM((pks=pk) * (dates < d))+1)), FILTER(in, rnk=1))
Here is the output:

The name rnk
, ranks each element of the same group, assigning the value 1
to the oldest date. This approach doesn't require sorting the data, SUM
calculation ensures it. So the output is presented in the same order as the input, just removing duplicates.
Note: In this case, there is no risk of false positives by concatenation (in the way it was built the primary key), because the delimiter (_
) cannot be present in the dates or zipcodes. Check the comment section from @JvdV's answer to this question: Finding pairs of cells in two columns. Just for fun, we can avoid using concatenation and keep the same approach, via MMULT
to identify the groups (grs
) for each row, where grId
is the group id, in our case we have only 1
,2
.
=LET(in, A2:F4, pks, CHOOSECOLS(in,3,4,5), n, COLUMNS(pks), dates, INDEX(in,,2),
ux, UNIQUE(pks), grId, SEQUENCE(ROWS(ux)), ones, SEQUENCE(n,,1,0),
grs, BYROW(pks, LAMBDA(pk, FILTER(grId, MMULT(N(pk=ux), ones)=n))),
rnk, MAP(grs, dates,LAMBDA(g,d, SUM((grs=g)*(dates < d))+1)),FILTER(in,rnk=1))
Notice, this approach doesn't need to sort the input data.