Hi @Erec and @Eickhel,
If you want to avoid collections (and you definitely do if you're going to hit thousands of items which then have to be pulled down every time a refresh is done), you can create a slightly altered solution.
Your problem in the code you posted is that all your other items are just 'columns' whereas one of your items tries to reference the .Value of the column, which sharepoint is not able to delegate as a task on behalf of PowerApps (at time of writing).
If(
IsBlank(TextSearchBox1.Text),
SortByColumns(
Filter(
lsNearMissData,
ReportedBy= "Joe Bloggs"
),
"NearMissDate",
If(SortDescending1, Ascending, Descending)
),
SortByColumns(
Filter(
lsNearMissData,
StartsWith(Region.Value, TextSearchBox1.Text) && ReportedBy="Joe Bloggs"
||
StartsWith(ContractNoDeptCode, TextSearchBox1.Text) && ReportedBy="Joe Bloggs"
),
"NearMissDate",
If(SortDescending1,Ascending, Descending)
)
)
So solution would be to:
Create a new Text column in SharePoint, Call it RegionActualValue,
Refresh the data source in your app, add that column as a field within the gallery, set it's visible setting to false (its just a data-holder so that we can search in the gallery)
In any of your edit/new screens have your app fill the Default value of the Textbox within that RegionActualValue Card with Text(Region.Value) during every edit/new item (or go into SharePoint and retrospectively copy/paste the text value for all historic items).
Once those fields are filled, you can change your statement to:
If(
IsBlank(TextSearchBox1.Text),
SortByColumns(
Filter(
lsNearMissData,
ReportedBy= "Joe Bloggs"
),
"NearMissDate",
If(SortDescending1, Ascending, Descending)
),
SortByColumns(
Filter(
lsNearMissData,
StartsWith(RegionActualValue, TextSearchBox1.Text) && ReportedBy="Joe Bloggs"
||
StartsWith(ContractNoDeptCode, TextSearchBox1.Text) && ReportedBy="Joe Bloggs"
),
"NearMissDate",
If(SortDescending1,Ascending, Descending)
)
)
Which should then be Delegable,
Could you let me know if you get any further delegation errors from it and if so, then where it has underlined?
Cheers,
ManCat