Do you know how to sort Power Apps Gallery by ID? No problem!
In this Power Apps tutorial, I will explain how to sort Power Apps Gallery by ID from SharePoint List.
Also, we will see how to work with Power Apps Sort Gallery By ID [from SharePoint Custom Column] with various examples.
How to Sort Power Apps Gallery By ID
I will take two examples to sort Power Apps Gallery By ID here.
Example – 1:
In this scenario, we will see how to sort the gallery record using the SharePoint ID field. It’s so simple to achieve this.
Setup a SharePoint List
I have a SharePoint Online list named TSInfo Attachments. This list has various columns with different data types:
|Title||Single line of text|
|Attachment Types||Choice [PPT, PDF. Microsoft Document, Excel]|
Sort Gallery By ID in Power Apps
1. In Power Apps, there is a Text input control and a Gallery control. All the gallery records are retrieved from the SharePoint list.
2. When the search box is empty, the gallery will appear with all the SharePoint list records.
3. When a user enters any file name in the search box, the gallery filters according to user search-related records in descending order (based on ID values), as seen below.
4. To work around this, we will use the below formula on the gallery’s Items property:
Items = SortByColumns( Filter( 'TSInfo Attachments', StartsWith( Title, txtSearchFile.Text ) ), "ID", SortOrder.Descending )
- ‘TSInfo Attachments‘ = SharePoint list name
- StartsWith = This Power Apps function helps test whether a text string begins with another. To know more details about this post, go through this complete tutorial: Power Apps StartsWith and EndsWith Functions
- Title = Single line of text field that the user will search in the search box
- txtSearchFile = Text input control name where the user will search the file name
- “ID” = Specify the SharePoint ID field name that you want to sort
5. Save and preview the app. When you enter a search term (like PowerApps) into the search box, the gallery will filter and display the results according to the ID field (in descending order).
This is how to work with Power Apps sort by ID.
Example – 2:
In this scenario, we will see how to sort the Power Apps gallery by ID from the SharePoint list [Custom ID Column].
Setup a SharePoint List
The screenshot below represents a SharePoint list named Employee Onboarding. This list has these many columns:
|Employee Name||Single line of text|
|Department||Choice [HR, IT, FINANCE, MARKETING]|
Also, this list has these many below records. Refer to the image below.
Power Apps Sort Gallery By ID
1. In Power Apps, there is a Vertical Gallery control with all the records from the SharePoint list.
2. All gallery records are arranged by Employee ID in descending order, as seen in the screen below.
3. To work with it, select the gallery control and set its Items property to the code below:
Items = Sort( 'Employee Onboarding', 'Employee ID', SortOrder.Descending )
- ‘Employee Onboarding’ = SharePoint list name
- ‘Employee ID’ = SharePoint Number Field [Custom column]
4. Once we save and preview the app, the gallery will appear in descending order with the SharePoint Employee ID column.
This is how to work with Power Apps Sort Gallery By ID.
I hope you got an idea about how to sort Power Apps Gallery by ID from the SharePoint List.
Also, in this article, we learned how to work with Power Apps Sort Gallery By ID [from SharePoint Custom Column] with various examples.
Also, you may like some more Power Apps tutorials:
- Power Apps Sort() Function
- Sort Gallery by Person Column in Power Apps
- Sort Dropdown Choices Alphabetically in Power Apps
- Power Apps Sort Distinct Filter
- Power Apps Sort Gallery
- Power Apps Filter Gallery By Last Week
- Power Apps Gallery Conditional Formatting
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