Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

How to order SharePoint items returned by ‘Get items’ in Power Automate

Posted on May 12, 2021May 12, 2021 by Tom

“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
Title asc
Order SharePoint items in Power Automate

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
Order SharePoint items Power Automate by multiple columns

Summary

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.

And if you’d like to filter the items before that, take a look on the filtering section on the blog.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

4 thoughts on “How to order SharePoint items returned by ‘Get items’ in Power Automate”

  1. Mike says:
    April 29, 2022 at 10:10 pm

    Hi

    Have you tried looping through the ordered get items. If I use apply to each based on the get items order by, in my case asc, the order is not in really in ascending order. It might start with A’s and B’s but then jumps to W and then back B etc – thanks

    Reply
    1. Tom says:
      May 3, 2022 at 8:09 pm

      Hello Mike,
      I didn’t notice anything like that, did you try adding ‘Select’ to select only the sort property to confirm the order? I can imagine it could happen also if you used some level of parallelism in the ‘Apply to each’ that some items would be processed faster than others.
      But if that’s really broken then I’m afraid there’s no other easy way how to sort the returned items.

      Reply
  2. Zoe says:
    June 12, 2022 at 7:30 pm

    Hi

    Thank you very much. I found this website is very useful.
    I want to order a list by a lookup value. The way I tried was to use get item/order by/use the lookup field name in the address ( everything after ‘Field=’). However the system told me the field name can not be found. is there other way to use lookup value to order a list? thank you

    Reply
    1. Tom says:
      June 19, 2022 at 9:50 am

      Hello Zoe,
      there’re the same rules as when filtering using the lookup columns. You must use the internal name + by which value it should sort, e.g.
      Lookup/Id asc = ascending by Id in the lookup list
      Lookup/Title desc = descending by the displayed value from the lookup list

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Format results of date calculation in SharePoint columnJune 29, 2022
  • Why is your Power Automate flow creating duplicatesJune 26, 2022
  • How to create a unique identifier in your Power Automate flowJune 22, 2022
  • How to assign custom SharePoint permission level with Power AutomateJune 19, 2022
  • Remove permissions from a specific SharePoint user with Power AutomateJune 15, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme