I have a powerapps application that I have implemented sorting on columns of a gallery, but now the requirement is to also be able to search across the columns in the gallery. How do I add "Search" to the code below?
Switch(
locSortColumn,
"DataSource", Sort( Filter(KED_DistributorItems,KED_BrandItemId=Blank()), DataSource, If(locSortAscending, SortOrder.Ascending, SortOrder.Descending)),
"MfgrName", Sort(Filter(KED_DistributorItems,KED_BrandItemId=Blank()), MfgrName, If(locSortAscending, SortOrder.Ascending, SortOrder.Descending)),
"MfgrItemCode", Sort(Filter(KED_DistributorItems,KED_BrandItemId=Blank()), MfgrItemCode, If(locSortAscending, SortOrder.Ascending, SortOrder.Descending)),
"ProductNumber", Sort(Filter(KED_DistributorItems,KED_BrandItemId=Blank()), ProductNumber, If(locSortAscending, SortOrder.Ascending, SortOrder.Descending)),
"ProductDescription", Sort(Filter(KED_DistributorItems,KED_BrandItemId=Blank()), ProductDescription, If(locSortAscending, SortOrder.Ascending, SortOrder.Descending)),
"Created", Sort(Filter(KED_DistributorItems,KED_BrandItemId=Blank()), Created, If(locSortAscending, SortOrder.Ascending, SortOrder.Descending)),
"LastTrans", Sort(Filter(KED_DistributorItems,KED_BrandItemId=Blank()), LastTransactionDate, If(locSortAscending, SortOrder.Ascending, SortOrder.Descending)),
"LastSpend", Sort(Filter(KED_DistributorItems,KED_BrandItemId=Blank()), Last12MonthSpend, If(locSortAscending, SortOrder.Ascending, SortOrder.Descending)),
Sort(Filter(KED_DistributorItems,KED_BrandItemId=Blank()), Created, SortOrder.Descending)
)
Yes, these formulas tend to get messy once you have to implement search-filter-sort.
Here are some thoughts to help you:
Sort(Filter(...),Switch(locSortColumn,"Created",Created,...))