cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stefansc
Level: Powered On

Sort / Search in data table not working

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
stefansc
Level: Powered On

Re: Sort / Search in data table not working

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.

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Sort / Search in data table not working

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
Level: Powered On

Re: Sort / Search in data table not working

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.

stefansc
Level: Powered On

Re: Sort / Search in data table not working

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.

View solution in original post

Super User
Super User

Re: Sort / Search in data table not working

Hi @stefansc,

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 85 members 5,391 guests
Please welcome our newest community members: