cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stefansc
Helper I
Helper I

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

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
timl
Super User III
Super User III

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
)

 

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.

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

Drrickryp
Super User II
Super User II

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,214)