web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PowerApps Search and S...
Power Apps
Answered

PowerApps Search and Sort Gallery

(0) ShareShare
ReportReport
Posted on by 145

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?

 

PowerAppsGallery.gif

 

 

 

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)
)

 

 

 

 

 

Categories:
I have the same question (0)
  • jlk1 Profile Picture
    88 on at

    Not fully sure if it would work but putting a text input and then adding "StartsWith(Title, TextSearchBox1.Text)" to the filters should work?

  • tjestesjr Profile Picture
    145 on at

    The requirement is to have 1 text box to search across all columns. 

  • madlad Profile Picture
    2,637 Moderator on at

    You likely want to use the Search function, probably wrapped around your current statement, with one text input and all necessary columns specified.

  • tjestesjr Profile Picture
    145 on at

    So I wrapped my Sort function in a Search function and the Search works by itself but then causes the Sort function to fail.

     

    Search(
    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)
     ),txtDistItemsSrch.Text,"DataSource")

     Any ideas on how to get both functionalities to work? 

  • madlad Profile Picture
    2,637 Moderator on at

    Maybe try wrap a search() around each sort, to avoid having the switch within a search? 

  • Verified answer
    mfvelazquez Profile Picture
    17 on at

    Use the SortByColumns function instead.

    You can also use the With function to improve the readability of the formula.

    The following formula should work. 

     

     

    With(
     {
     wLocSortColumn:locSortColumn,
     wFilteredData: Filter(KED_DistributorItems,KED_BrandItemId=Blank())
     }
     SortByColumns(
     Search(
     wFilteredData,
     txtDistItemsSrch.Text,
     "DataSource",
     "MfgrName",
     "MfgrItemCode",
     "ProductNumber",
     "ProductDescription",
     "Created",
     "LastTransactionDate",
     "Last12MonthSpend",
     ), 
     wLocSortColumn, 
     If(locSortAscending,SortOrder.Ascending,SortOrder.Descending)
     )
    )

     

     

  • tjestesjr Profile Picture
    145 on at

    I have implemented sorting by each column in the application within the gallery using a chevron icon (see screenshot above). I am not sure how to implement the SortByColumns with these control, can you explain further?

  • mfvelazquez Profile Picture
    17 on at

    Use the formula as I wrote it. It should work.

     

    The SortByColumns is using the wLocSortColumn dynamic value that is getting value from your LocSortColumn variable I think you're setting up using the Chevron icon.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard