I recently created a Power Apps form with a combo box control containing country names as items. To reduce the search time, I sorted the combo box items alphabetically. Users can scroll through the combo box items based on the first letter and easily select their country name.
In this article, I will explain the 6 various ways to sort Power Apps Combo box items.
Sort Power Apps Combo Box Items From the Collection
Let’s see how to sort the items in the combo box control where the items are added from the Power Apps collection.
The Power Apps combo box items are sorted in ascending order in the example below.
Follow the steps below to achieve this!
1. To create a Power Apps collection, provide the code below in the OnStart property of the App object.
ClearCollect(
colCountryNames,
{Countryname: "Brazil"},
{Countryname: "Myanmar"},
{Countryname: "Bolivia"},
{Countryname: "Sri Lanka"},
{Countryname: "Indonesia"},
{Countryname: "Malaysia"},
{Countryname: "Philippines"},
{Countryname: "Canada"},
{Countryname: "Algeria"},
{Countryname: "India"}
)
2. Add a Combo box control from the +Insert tab in Power Apps and provide the below formula in its Items property.
Sort(colCountryNames.Countryname,Countryname,SortOrder.Ascending)
The Sort() function sorts the collection items in the Power Apps combo box control in ascending order.
- colCountryNames is the collection name
- Countryname is the collection column header name.
Now, save and preview the app. The Power Apps combo box collection items are displayed in ascending order.
This way, we can sort the items in the Power Apps combo box control if it takes values from the collection.
Sort Power Apps Combo box items From the SharePoint List
Here, we’ll see how to sort the combo box items where items are taken from the SharePoint list. The example below shows that the SharePoint list items in the Power Apps combo box are sorted in descending order.
The Power Apps combo box values are taken from the SharePoint list named Project Details List below.
Follow the steps below to achieve this!
1. Connect the SharePoint list with Power Apps. Then, add a combo box control from the +Insert tab.
2. Provide the formula below in the Items property of the Power Apps combo box control to display the project names.
Distinct('Project Details List',Title)
Power Apps Distinct function will remove the duplicate values and return unique values to the Power Apps combo box control.
Then, it will display the project names in a combo box, similar to how we stored them in the SharePoint list.
3. To sort the project names in the Power Apps combo box control, provide the formula below for its Items property.
Sort(Distinct('Project Details List',Title),Value,SortOrder.Descending)
Here, the sort function will sort the items in the Power Apps combo box in descending order.
4. Save the changes and preview the app once. The Power Apps combo box control items are sorted in descending order.
I hope you understand how to sort the Power Apps combo box items where items are taken from the SharePoint list.
Power Apps Sort Combo Box Choice Field
Let’s see how to sort the Power Apps combo box control values. Where the combo box items are taken from the SharePoint list choice field.
The image below shows that the Power Apps combo box items are sorted in ascending order.
Here is the SharePoint list named Expense Report Form and the choice column [Expense Category].
To do this, follow the steps below!
1. Connect the SharePoint list with Power Apps. Add a Combo box control and provide the formula below in its Items property to get the SharePoint list choice field values.
Choices([@'Expense Report Form'].'Expense Category')
Change the Expense Report Form with the SharePoint list name and Expense Category with your choice column name.
2. Save changes and preview the app once. The Power Apps combo box control will display the choice field values.
3. To sort the Power Apps combo box values, provide the formula below in its Items property.
Sort(Choices([@'Expense Report Form'].'Expense Category')
,Value,SortOrder.Ascending)
The sort function will sort the SharePoint list choice values in the Power Apps combo box in ascending order.
4. Now, save and preview the app. The items in the combo box control were sorted in ascending order.
Power Apps Sort Combo Box Date Field
We have seen how to sort the SharePoint list choice and title fields in the Power Apps combo box control. Let’s see how to get the SharePoint list date field in the Power Apps combo box and then how to sort the date values.
Here is the SharePoint list named Expense Report Form with Date field.
To do this, follow the steps below!
1. In Power Apps, connect with the SharePoint list from the Data section. Then, add a combo box control.
2. Provide the formula below in the Items property of the Power Apps combo box control to get the date values.
Distinct('Expense Report Form',Date)
3. To format the date field values and to sort the dates in the Power Apps combo box, provide the formula below in the Items property.
Distinct(Sort('Expense Report Form'.Date,Date),Text(Date,"[$-en-US]dd/mm/yyyy"))
The Text function changes the date format to dd/mm/yyyy. The sort function sorts the date values in the combo box in ascending order.
Now, save and preview the app once you can see the dates in the Power Apps combo box are sorted in ascending order.
Sort Power Apps Combo Box Alphabetically
Here, I will explain how to alphabetically sort the Power Apps combo box. I have a SharePoint list named Teams Details.
The Power Apps combo box control below displays the Team Name field from the above SharePoint list in alphabetical order.
To achieve this, follow the steps below!
1. In Power Apps, connect with the SharePoint list from the Data section. Then, add a combo box control.
2. Provide the formula below in the Items property of the combo box. To get the SharePoint list team name field values and sort them alphabetically
Sort(Distinct('Teams List',Title),Value)
This sort function, by default, sorts the combo box values alphabetically if we don’t provide any sort order.
Save the changes and preview the app once. The Power Apps combo box control team names will be sorted alphabetically.
Power Apps Sort Combo Box Search Microsoft 365 Users
I have a combo box control in Power Apps containing the Microsoft 365 users. To track all the users, I sorted them in ascending order, as in the example below.
To achieve this, follow the steps below!
1. Connect Power Apps with Office365Users connector from the Data section.
2. To sort and get the Microsoft 365 users, provide the below formula in the Items property of the Power Apps combo box control.
Sort(Office365Users.SearchUser({searchTerm:'cmb_offcie 365'.SearchText}).DisplayName,DisplayName,SortOrder.Ascending)
Here, cmb_offcie 365 is the name of the combo box control. Office365Users.SearchUser will allow us to search for Microsoft 365 users in the Power Apps combo box control.
Save and Publish the app. The Microsoft 365 users will be displayed in ascending order.
This way, we can sort the Microsoft 365 users present in the Power Apps combo box control.
I hope you found this helpful article! I have explained various examples of sorting Power Apps combo box control in both orders.
Follow this article if you’re trying to sort the Power Apps combo box items.
Also, you may like:
- Set Combo Box Value On Button Click in Power Apps
- Power Apps cascading dropdown
- How to sort the Power Apps collection alphabetically
- Power Apps sort distinct and filter functions
- Power App’s modern dropdown 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