@christian12
It works for all case for me. See the code below where there are 3 same dates with the last 2 characters as 01, 06 and 12 and the code only returns the 12 record, ie
Add this code to a button and test
ClearCollect(
colMatches,
{VALUE: 111, DATE: Date( 2021, 9, 28), ID: "2021-09-28"},
{VALUE: 121, DATE: Date( 2022, 5, 26), ID: "2022-05-26"},
{VALUE: 121, DATE: Date( 2022, 6, 1), ID: "2022-06-01"},
{VALUE: 121, DATE: Date( 2022, 6, 1), ID: "2022-06-06"},
{VALUE: 121, DATE: Date( 2022, 6, 1), ID: "2022-06-12"},
{VALUE: 117, DATE: Date( 2022, 2, 4), ID: "2022-02-04"},
{VALUE: 117, DATE: Date( 2022, 2, 4), ID: "2022-02-10"}
);
RemoveIf(
colMatches,
!(ID in
ForAll(
colMatches As _data,
If(
CountRows( Filter(colMatches, DATE = _data.DATE)) = 1 ||
Value( Right( _data.ID,2)) = Value( Right( First(Sort( Filter(colMatches, DATE = _data.DATE), ID, SortOrder.Descending)).ID, 2)),
{
VALUE: _data.VALUE,
DATE: _data.DATE,
ID: _data.ID
}
)
).ID
)
)
The only time this code won't work is if you get more than 99 records with the same date (ie last 2 characters are 99)