Firstly
@MMcCloud may be on the right track here - either one/more of
SortStatusDrop,
SortEMpDrop or
Searchbar are inside the gallery or you have a calculated field in the gallery relying on the output of one/more of these.
Also, you can condense your code a bit here. Firstly if the output of the filter will always be under your Data Row Limit, you can do this (note you posted Status in both filters instead of referring to EmpNo on one).
With(
{
_Data:
Filter(
Projects,
Status = SortStatusDrop.Selected.ID,
Status > 1,
Status < 11 Or Status = 13,
Len(Searchbar.Selected.ID) = 0 Or Client = Searchbar.Selected.ID
)
},
Sort(
_Data,
If(
SortByStatus,
Status,
SortByEmp,
EmpNo,
ID
),
SortOrder.Ascending
)
)
If however it is possible for the record numbers to be bigger, you can do this
If(
SortByStatus,
Sort(
Filter(
Projects,
Status = SortStatusDrop.Selected.ID,
Status > 1,
Status < 11 Or Status = 13,
Len(Searchbar.Selected.ID) = 0 Or Client = Searchbar.Selected.ID
),
Status,
SortOrder.Ascending
),
SortByEmp,
Sort(
Filter(
Projects,
Status = SortStatusDrop.Selected.ID,
Status > 1,
Status < 11 Or Status = 13,
Len(Searchbar.Selected.ID) = 0 Or Client = Searchbar.Selected.ID
),
EmpNo,
SortOrder.Ascending
),
Filter(
Projects,
Status = SortStatusDrop.Selected.ID,
Status > 1,
Status < 11 Or Status = 13,
Len(Searchbar.Selected.ID) = 0 Or Client = Searchbar.Selected.ID
)
)
Note also that varSort seems a bit of a waste of time - if neither SortByStatus or SortByEmp are true, then varSort is also false.
Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like ♥
Visit my blog Practical Power Apps LinkedIn