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 Name | Data Type |
Product Name | Default single line of text |
Manufacturer | Choice |
Price | Currency |
Purchase Date | Date and time |
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.
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
2. Save, Publish, and Preview the app. The Power Apps gallery control will display the SharePoint list record in ascending order as shown below.
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:
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
)
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.
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:
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
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
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.
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:
- Customize a Power Apps Gallery Layout
- Display SharePoint List Items in PowerApps Gallery
- Sort Power Apps Gallery by Choice Column
- Power Apps Sort Gallery By Calculated Field
- Count Rows in Power Apps Gallery Control
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