How to order SharePoint items returned by ‘Get items’ in Power Automate
Posted On May 12, 2021
“Is it possible to use multiple fields in the ‘Order By’ Power Automate OData filter on a SharePoint ‘Get items’ action? i.e. sort by Title and Date field?”
Power Automate action ‘Get items’ will always return the SharePoint items in an order, by default ascending by ID – the oldest items first. In most situations the order doesn’t really matter, but there’re some cases when it does. For example, if you export the SharePoint list items into an HTML table, it makes sense to sort it differently. It’s always easier to read an export if you group the related items together, e.g. requests for a specific user.
Since Power Automate doesn’t have an action to sort an array later, you should sort the results right away. There’s a workaround to sort an array, but with SharePoint items it’s an extra work. If you can sort the items directly in ‘Get items’, you should do it.
‘Order By’ format
The expected format of the ‘Order By’ field is very simple. Type in the SharePoint column internal name and the order: asc for ascending or desc for descending.
e.g. ascending by Title
If one column is not enough, you can order by multiple columns, just separate the columns and order by a comma. The sorting priority will be from the left to the right.
e.g. ascending by Title, then descending by DateTime
Title asc, DateTime desc
As already mentioned, if you need to sort the items, you should do it right away. The ‘Get items’ action gives you the possibility in the ‘Order By’ field – just define the columns and their sorting order.