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 / Sort / Search in data ...
Power Apps
Answered

Sort / Search in data table not working

(0) ShareShare
ReportReport
Posted on by 89

Hi,

 

I'm a newbie with Powerapps. I've just created a data table from an Excel file but I'm not able to sort columns or search the data table.

screen1.JPG

 

In the onSelect Action of the sort button for CompanyCode I entered the formula

SortByColumns(Costcenters,"CompanyCode",Ascending)

 

On the search button I set the following formula in the onSelect action:

Search(Costcenters,SearchBar.Text,"Company","CompanyCode","Cost center no","Department","Description")

 

Neither the sort nor the search function is working.

 

Categories:
  • timl Profile Picture
    37,355 Super User 2026 Season 2 on at

    Hi @stefansc

    With PowerApps, we apply the data source formulas to the Items property of the control that displays the data, rather than the OnSelect property of a button.

    Therefore, if you apply this formula to the Items property of your data table control, you should have more success.

    Search(Costcenters,
     SearchBar.Text,
     "Company","CompanyCode","Cost center no","Department","Description"
    )

    You can also nest these formulas. To sort the items in your data table, you can use this syntax.

    SortByColumns(Search(Costcenters,
     SearchBar.Text,
     "Company","CompanyCode","Cost center no","Department","Description"),
     "CompanyCode",
     Ascending
    )

     

  • stefansc Profile Picture
    89 on at

    Hi timl,

     

    I've added the formula

    SortByColumns(Search(Costcenters,
     SearchBar.Text,
     "Company","CompanyCode","Cost center no","Department","Description"),
     "CompanyCode",
     Ascending
    )

    to the items property.

    The search works fine but I'm not able to sort the columns.

  • Verified answer
    stefansc Profile Picture
    89 on at

    Ok, got it.

    Just added

    UpdateContext({Sortfield:"CompanyCode"})

    UpdateContext({Sortfield:"Company"}) ....

    to the onSelect action in the column header buttons and changed the items property of the data table to

     

    SortByColumns(Search(Costcenters, SearchBar.Text,
                         "Company","CompanyCode","Cost center no","Department","Description"),
                  Sortfield,
                  Ascending
    )

     

    referring to the Sortfield variable.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @stefansc,

    If you have the answer to your issue, please mark the discussion as solved so that others can find it.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 337 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard