How to Sort Power Apps Gallery Alphabetically?

Have you ever sorted Power Apps Gallery alphabetically? Follow this Power Apps tutorial to learn how to sort Power Apps gallery alphabetically. Like:

  • How to Sort Power Apps Gallery Ascending [A-Z]
  • Sort Power Apps Gallery Control Descending [Z-A]
  • Sort Power Apps Gallery Ascending Descending

How to Sort Power Apps Gallery Ascending [A-Z]

Here, we will discuss how to sort Power Apps gallery items in ascending order with a simple scenario.

Scenario:

I have a SharePoint Online list named [Product Details], and inside this, I added Product records using various columns with different data types.

Column NameData Type
Product NameDefault single line of text
ManufacturerChoice
PriceCurrency
Purchase DateDate and time
Sort power apps gallery ascending descending

In Power Apps, I have created a Gallery control that is connected to my SharePoint list. Now, I want to display the SharePoint records in ascending order based on the “Title” column, as in the screenshot below.

Sort power apps gallery control ascending descending

To work around this example, follow the below steps. Such as:

1. Create Power Apps Canvas app -> Connect it to the respective SharePoint list -> Insert a Gallery control -> Set its Items Property as:

Items = Sort(
    'Product Details',
    Title,
    SortOrder.Ascending
)

Where,

  • Sort() = This Power Apps Sort() function helps us to sort the table depending on the formula
  • ‘Product Details’ = SharePoint Online List
  • Title = SharePoint Title Field
Sort power apps gallery control ascending

2. Save, Publish, and Preview the app. The Power Apps gallery control will display the SharePoint list record in ascending order as shown below.

How to Sort power apps gallery control ascending

This is how to sort Power Apps gallery items in ascending order.

Sort Power Apps Gallery Control Descending [Z-A]

Next, we will see how to sort Power Apps gallery control in descending order.

Example:

I will also take the above Gallery control for this example. Now, I want to display the SharePoint list items on a Gallery control in descending order.

Refer to the below screenshot:

Sort power apps gallery descending

To do so, follow the below steps.

1. On the Power Apps Screen -> Select the Gallery control and set its Items Property to the code below.

Items = Sort(
    'Product Details',
    Title,
    SortOrder.Descending
)
How to Sort power apps gallery descending

2. Save, Publish, and Preview the app. The Power Apps gallery control will display the SharePoint list items in descending order, as in the screenshot below.

Sort power apps gallery control descending

This is how to sort Power Apps gallery items in descending order [Z-A].

Sort Power Apps Gallery Ascending Descending

In the last, we will see how to sort the Power Apps gallery in ascending order, and vice versa in descending order.

Example:

Here, I will also take the above gallery control for this example. Whenever a user selects a Sort icon, the gallery displays items in ascending order, and vice versa, when the user again taps on the same sort icon, the gallery displays items in descending order.

Refer to the below screenshot:

How to sort a power apps gallery control ascending descending

To achieve it, follow the below steps. Such as:

1. On the Power Apps Screen -> 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
How to sort power apps gallery ascending descending

2. Then, select a Gallery control and set its Items property as:

Items = SortByColumns(
    'Product Details',
    varColumn,
    varOrder
)

Where,

  • ‘Product Details’ = SharePoint Online List
  • varColumn, varOrder = Power Apps Global Variables
How to sort a power apps gallery ascending descending

3. Once your app is ready, just Save, Publish, and Preview the app. The Power Apps gallery control will display the SharePoint list records based on the selecting sort icon [Either ascending Or descending] like below.

How to sort the power apps gallery ascending descending

This is how to sort Power Apps gallery control ascending or descending.

Conclusion

From this Power Apps tutorial, we learned all about how to sort the Power Apps Gallery alphabetically. Like:

  • How to Sort Power Apps Gallery Ascending [A-Z]
  • Sort Power Apps Gallery Control Descending [Z-A]
  • Sort Power Apps Gallery Ascending Descending

You may also like:

>