I have a table for which I am trying to get the most recent record only for each Id according to the created column
ClearCollect(TestList,
{Id: 1, created: 1, desc: "Lorem"},
{Id: 2, created: 3, desc: "Ipsum"},
{Id: 2, created: 2, desc: "Dolar"},
{Id: 3, created: 4, desc: "Sit"},
{Id: 1, created: 4, desc: "Amet"})
I thought I could group the table, sort each resulting table by the created column, keep the first record and then ungroup again.
ClearCollect(filteredList,
Ungroup(
ForAll(
GroupBy(TestList, "Id", "Result"),
{Id: ThisRecord.Id, Result: First(Sort(ThisRecord.Result, created, SortOrder.Descending))}),
"Result")
)
However, the Ungroup function doesn't seem to be ungrouping the table in the results column and I am left with a grouped table:
Any help much appreciated!