When you are working with the Power Apps data table, you may want to sort the Power Apps data table. Thankfully, there are two Power Apps functions, i.e., [Sort() and SortByColumn()], to sort the Power Apps data table records.
In this article, I will explain how to sort data table in Power Apps with real-time examples. Also, we will discuss how to sort and filter the Power Apps data table.
How to Sort Data Table in Power Apps
While working with the Power Apps Data table control, we usually need to sort the data table per our requirements. Now, I will show you how to sort the Power Apps data table in different scenarios. Such as:
- How to Sort Power Apps Data Table Alphabetically [A-Z or Z-A]
- Sort Power Apps Data Table By Ascending and Descending
- How to Sort and Filter Power Apps Data Table
Sort Power Apps Data Table Alphabetically
I have a Power Apps data table that retrieves all the records from my Power Apps collection [colEventRegistration], as in the screenshot below.

Now, I would like to sort the Power Apps data table Alphabetically [Ascending or Descending]. Have a look at the below output.

To work around this, follow the below steps. Such as:
1. Open Power Apps with your respective Microsoft credentials -> Create a Blank canvas app -> Select App object and set its OnStart property to the code below.
OnStart = ClearCollect(
colEventRegistration,
{
Name: "John Smith",
CompanyName: "Buckeyee Furniture",
Occupation: "Training and development specialist",
Age: 34,
Gender: "Female"
},
{
Name: "Emma Reyna",
CompanyName: "Fox valley CPAs",
Occupation: "Accountant",
Age: 32,
Gender: "Female"
},
{
Name: "Kelven",
CompanyName: "Bugle Boy",
Occupation: "Daimond Tracker",
Age: 44,
Gender: "Male"
},
{
Name: "Lynee",
CompanyName: "Specific Appraisals",
Occupation: "Computer and Information Researcher",
Age: 40,
Gender: "Male"
},
{
Name: "Steve Mroz",
CompanyName: "Maxigraphics",
Occupation: "Graphic Designer",
Age: 39,
Gender: "Male"
},
{
Name: "Henrita Mullar",
CompanyName: "Happy Harry's",
Occupation: "Customer Suppot Executive",
Age: 36,
Gender: "Female"
}
)
Where,
- colEventRegistration = Power Apps Collection Name
- Name, CompanyName, Occupation, Age, Gender = Collection Headers/Columns
- “John Smith”, “Buckeyee Furniture”, “Training and development specialist” = Collection Records/Rows

2. On the Power Apps Screen -> Insert a Data table control and set its Items property to the code below.
Items = Sort(
colEventRegistration,
Name
)
Where,
- Sort() = Power Apps Sort() function helps us to sort the table depending on the formula
- colEventRegistration = Power Apps collection name
- Name = Collection text field

3. Once your app is ready, Save, Publish, and Preview the app. The data table sorts and displays each record from the collection based on the ascending order [A-Z] like below.

4. Also, if you want to sort the Power Apps data table in descending order [Z-A] then select the Data table and set its Items property as:
Items = SortByColumns(
colEventRegistration,
"Name",
SortOrder.Descending
)

5. Look at the screenshot below to see how we can sort the Power Apps data table records in descending order.
This way, we can sort the Power Apps data table alphabetically.

Sort Power Apps Data Table By Ascending and Descending
Here, I will show you how to sort the Power Apps data table by ascending and descending with a simple example.
Example:
I have a SharePoint Online list named “Vacation Budget” and this list contains the below fields.
Input:
Column Name | Data Type |
Destination | It is a default single line of text |
Expense Name | A single line of text |
Category | Choice |
Estimated Cost | Currency |
Number Of People | Number |

In Power Apps, there is a Sort icon and a Data table [It retrieves all the records from the SharePoint list]. Whenever the user clicks on the sort icon, it will sort the data table records in either ascending or descending order based on the SharePoint list title field [Destination].
Output:

To do so, follow the below steps.
1. On the Power Apps app -> Select the App object and set its OnStart property as:
OnStart = ClearCollect(
colVacations,
'Vacation Budget'
)
Where,
- colVacations = Power Apps collection
- ‘Vacation Budget’ = SharePoint Online list

2. Next, insert a Sort icon and set its OnSelect property to the code below.
OnSelect = Set(
varColumn,
"Title"
);
Set(
varOrder,
If(
varOrder = SortOrder.Ascending,
SortOrder.Descending,
SortOrder.Ascending
)
)
Where,
- varColumn = 1st Global Variable Name
- “Title” = SharePoint Title Field
- varOrder = 2nd Global Variable Name
- SortOrder.Descending, SortOrder.Ascending = Sort order can be either ascending or descending

3. Now, insert a Data table control and set its Items property as:
Items = SortByColumns(
colVacations,
varColumn,
varOrder
)
Where,
- colVacations = Power Apps Collection
- varColumn, varOrder = Power Apps Global Variables

4. Save, Publish, and Preview the app. The Data table displays sorted records based on the selecting sort icon [Either ascending or descending] like below.

How to Sort and Filter Power Apps Data Table
Let’s see how to sort and filter the Power Apps data table with a simple scenario.
Scenario:
In Power Apps, there is a Data table control [It retries data from SharePoint list]. I want to sort the data table in Ascending order and filter the gallery based on the SharePoint choice field value [Category is equal to Entertainment].
Have a look at the screenshot below for the output:

To achieve this, follow the below steps. Such as:
1. On the Power Apps Screen -> Insert a Data table control and set its Items property to the code below.
Items = Sort(
Filter(
'Vacation Budget',
Category.Value = "Entertainment"
),
Title,
SortOrder.Ascending
)
Where,
- Sort() = Power Apps Sort() function helps us to sort the table depending on the formula
- Filter() = This function is used to find a set of records that match one or more criteria and to discard those that don’t
- ‘Vacation Budget’ = SharePoint Online list
- Category, Title = SharePoint list fields

2. Once your app is ready, Save, Publish, and Preview the app. The Power Apps data table sorts and filters each record from the SharePoint Online list based on the choice field. Have a look at the below screenshot for the output.
This way, we can sort and filter the Power Apps data table.

This Power Apps tutorial taught us all about Sorting a Power Apps data table in different ways. If you have any requirements to work with the Sorting a Power Apps data table, you can follow the above ways.
Also, rRefer to some more below Power Apps posts:
- Filter Power Apps Data table in Power Apps
- Filter Power Apps Data Table using Checkbox
- Filter Multiple Person Column in Power Apps
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com