I want to sort some data (originally from a SharePoint list) in Flow.
I cannot sort at the 'SharePoint get items' action because I also need to filter the data by a *LookUp* field, but that is not supported by that action.
As a work-around to the filtering limitation, I sort in the 'Get Items' step by the ID in descending order and return the last few hundred items as the list will grow to be very long and I am concerned that if I don't specify that I only need the most recent few hundred items, I'll hit a either a hard limit on the data returned or a performance issue.
Once I have the most recent few hundred items, I use a Filter step (which does allow filtering on a LookUp field) to get just the records I need.
So now I have the data I want, but it is in the wrong order (I need to iterate through it in an Apply To Each step to build a string to be added to an email). The field that I want to sort by *is* included in the data set, I just cannot see any action I can use to sort the data inside of Flow.
Is there any way to sort data within Flow? Seems odd that filtering is supported but sorting is not.
Please take a try to sort the data on the Get items OrderBy filter as link below:
Hi Alice @v-yuazh-msft
I can't do that as I am already using the Order By on the Get Items step to workaround the limitation whereby odata filters don't work on LookUp (complex) fields. As mentioned, I get around this by using the Order By to ensure I have the most recent 200 records (ordering be ID descending) as I know that will return all records I need. I then Filter those records using a Filter step (which does support filtering on LookUp fields). So I now have just the records I want, but in the wrong order.
Is there no way to sort records *within* Flow? Seems odd that I can filter a recordset within Flow but I cannot sort it.
Yes, there is no any way to sort records in microsoft Flow currently.
Sorting records is not supported in microsoft flow currently.
I afraid that there is no way to achieve your needs in Microsoft Flow currently.
If you would like this feature to be added in Microsoft Flow, please submit an idea to Flow Ideas Forum:
Thank you for posting on the Flow Community Forum! If you have already posted your idea to the Flow Community Ideas Forum or found an existing idea to upvote, then you need to post the URL to the idea’s thread as a reply to this thread. Then click "Accept as Solution" on the reply if you approve it as a solution to your issue so that other users may vote for the Flow Idea and identify the information easily within this thread.
Thank You for being an active member of the Flow Community!
Flow Community Manager
For the benefit of anyone else hitting a similar issue... I was able to filter by a complex field after all.
To filter a SharePoint 'Get Items' step by a complex field you can use:
Assessment/ID eq 5
Where Assessment is the name of the field and ID is one of the field attributes, eq is 'equals'.
Having figured out how to filter the data, I no longer needed to use 'Order By' as a workaround, so I was able to specify an 'Order By' and retrieve the data in the required sequence.
I still think the ability to sort data within Flow could be useful so have added that to the suggestions list.
Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.
Continue your learning in our online communities.
Features releasing from October 2019 through March 2020.
Fill out a quick form to claim your user group badge now!
Learn how to build the business apps that you need.
Find out where you can attend!
Watch & learn from the Flow Community Video Gallery!