Sorting Columns in the PowerApps Data Table

I’m hoping that by the time most people read this, native support for filtering and sorting the new Data Table control in PowerApps will be released, but since some users may be wanting this functionality now, here’s a quick guide to adding sorting to your columns:

In my sample app, I have added a Data Table and connected it to a simple SharePoint list.  This Data Table has 3 columns, and I have added Sort Icons on each column:

dt1

I have set the OnSelect property of each of these icons to UpdateContext to trigger the context to change on selection.  Each icon uses a separate context number so as to keep the variable separate:

UpdateContext({SortDescending1: !SortDescending1,SortField: “Title”})

UpdateContext({SortDescending2: !SortDescending2, SortField: “Location”})

UpdateContext({SortDescending3: !SortDescending3, SortField: “Status”})

Then I set the ‘Items’ property of the Data Table to the following:

If(SortField=”Title”, Sort(‘Item Tracking’, Title, If(SortDescending1, Descending, Ascending)),
If(SortField=”Location”, Sort(‘Item Tracking’, Location, If(SortDescending2, Descending, Ascending)),

If(SortField=”Status”, Sort(‘Item Tracking’, Status, If(SortDescending3, Descending, Ascending)),
‘Item Tracking’)))

Now, when ever you click one of the Sort buttons, it will sort that column either Ascending or toggle to Descending!

If you’d like to learn more about PowerApps, or are interested in building some for your organization, please feel free to reach out to me at joseph.karnes@centricconsulting.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: