Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

How to Sort Data Table in Power Apps?

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:

  1. How to Sort Power Apps Data Table Alphabetically [A-Z or Z-A]
  2. Sort Power Apps Data Table By Ascending and Descending
  3. 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.

Sort and filter Power Apps data table control

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

How to sort PowerApps Data table

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
How to Sort Data Table in Power Apps

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
How to Sort a Data Table in Power Apps

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.

How to Sort the Data Table in Power Apps

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
)
How to Sort Power Apps Data Table Alphabetically

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

This