@ChrisL58 - I think the below is what you're trying to do:
With(
{
_pre_filtered_data: Filter(
'BLC Goal Tracking',
Len(txtSearchBox.Text) = 0 || Colleague.DisplayName = txtSearchBox.Text
)
},
ForAll(
GroupBy(
AddColumns(
_pre_filtered_data,
ColleagueDisplayName,
Colleague.DisplayName
),
ColleagueDisplayName,
_items
),
First(
Sort(
_items,
Created,
SortOrder.Descending
)
)
)
)
Notes:
1. This solution is not delegable with any data source. However, this is mitigated somewhat so long as a Filter is applied prior to running the rest of the functions, and the output of that Filter does not exceed 500 rows (or max 2000 if increased via Settings).
2. Please be mindful that "shaping" or "transform" functions like AddColumns or GroupBy modify the table schema of your Gallery. If you have an Edit Form control which is bound to a selected item in the Gallery, this will result in an error.
The reason is because the table schema used in the DataSource and the Item property of the Edit Form must be the same. Given we have just modified the table schema in the Gallery, the table is now different to what the Item property of the Edit Form is expecting.
The typical workaround is to use a LookUp function in the Item property of your Edit Form to return the correct record:
LookUp(
'BLC Goal Tracking',
ID = 'Your Gallery'.Selected.ID