In this Power Apps Tutorial, we will see how to sort a dropdown control in Power Apps.
We recently received a request from one of our clients. While working with the Power Apps canvas app, they want to sort the items inside the dropdown control.
In detail we will discuss here:
- Sort a dropdown control in a Power Apps edit form
- Sort a dropdown control in a Power Apps gallery
- Sort Power Apps dropdown control alphabetically
Let’s see how to sort the items in ascending or descending order in a Power Apps dropdown control.
Sort a Power Apps dropdown control
In this section, we’ll look at various methods for sorting a Power Apps dropdown control. In addition, we will use various formulas to sort the dropdown items in the Power Apps edit form and gallery control.
Sort a dropdown control in a Power Apps edit form
In this section, we will see how to sort a dropdown control within a Power Apps edit form. As a result, it will let the user find their items in a descending or ascending order.
- There is a SharePoint list based on Project Management having different types of columns such as single line text column, date & time column, people column, etc. Also, the list has a choice column named ‘Project Location’.
- Let’s build an edit form inside the Power Apps canvas app. Connect that edit form with the SharePoint list. On the Power Apps canvas app screen, go to Insert > Edit form > Select.
- Connect the Power Apps edit form to the above SharePoint list as a data source.
- Automatically the form will appear with all the respective control as shown below:
- let’s remove the combo box control from the Project Location and add a Power Apps Dropdown control.
- To display the choices from the Project Location SharePoint column insert the below expression on the dropdown’s Items property.
Items = Choices([@'Projects Management'].'Project Location')
- On the above dropdown, the items are not sorted. To sort the above dropdown items, insert the below expression on the Power Apps dropdown’s Items property.
Items = Sort(
Choices([@'Projects Management'].'Project Location'),
Value
)
Also, you can use the below expression to sort a Power Apps dropdown control within the edit form.
Items = Sort(
Choices([@'Projects Management'].'Project Location'),
ThisRecord.Value,Descending
)
Once the formula is applied, we can see all the items are sorted in descending order as shown below:
This is how to sort Power Apps dropdown choices in ascending order.
Sort a dropdown control in a Power Apps gallery
Similarly, here we will see how to sort a dropdown control in a Power Apps gallery.
Here, we have prepared a Power Apps vertical gallery using the above SharePoint list named ‘Project Management’.
- On that gallery, add a dropdown control to let the user select the Project Location. For this, insert the below expression in the dropdown’s Items property to display the choices.
Items = Choices('Projects Management'.'Project Location')
- To sort the above Power Apps dropdown control, insert the below expression on the dropdown’s Items property.
Items = SortByColumns(
Choices('Projects Management'.'Project Location'),
"Value",
)
This is how to sort a Power Apps dropdown control within the gallery.
Sort Power Apps dropdown control alphabetically
In this section, we will see how to sort a Power Apps dropdown control alphabetically. Let’s build a Power Apps dropdown control using the project name and sort them alphabetically.
- Add a dropdown control to the Power Apps screen.
- Insert the below expression on the Items property of the dropdown control to display the projects’ names.
Items = 'Projects Management'.'Project Name'
- To sort the above dropdown alphabetically (descending or ascending), insert the above expression on the dropdown’s Items property.
Items = Sort(
'Projects Management',
'Project Name',
SortOrder.Descending
)
This is how to sort a Power Apps dropdown control alphabetically.
Conclusion
From this Power Apps tutorial, we learned how to sort a PowerApps dropdown control based on different scenarios such as:
- Sort a dropdown control in a Power Apps edit form
- Sort a dropdown control in a Power Apps gallery
- Sort Power Apps dropdown control alphabetically
You may also like:
- Power Automate Dataverse Update Multiple Rows
- How to Add a Time Picker in the Power Apps Canvas App?
- How to Highlight the Selected Item within a Power Apps Gallery?
- Patch Dataverse Choice Column in Power Apps
- Power Apps Table vs Collection
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.