web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Sort by Priority in Po...
Power Automate
Answered

Sort by Priority in Power Automate

(0) ShareShare
ReportReport
Posted on by

Hi,

 

I am a beginner to Power Automate and I am learning things as I am doing it. I built a flow which fetches the data from Azure DevOps Queries --> Creates HTML Table --> Sends email at scheduled time. Below is the screenshot:

hjoshi4u26_0-1670317663699.png

Output as shown below:

hjoshi4u26_1-1670317829308.png

(Had to redact the screenshot due to confidentiality clause of our company)

 

As you can see in above screenshot, the data sorting is random. I have to sort the data in the table by Priority field. I have tried sorting the data in Azure DevOps by Priority field, but that only works for DevOps. Power Automate does not fetch sorted data from DevOps. That means we have to do some tinkering in Power Automate itself.

Now I know there is an expression sort(), but it requires Array. I do not know in which step I have to use it.

Can anyone please help me with sorting the data by Priority in Ascending order..? It would be of great help

Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,876 Most Valuable Professional on at

    Hi @hjoshi4u26,

     

    You can apply that sort function in your Select actions with an expression in the From field.


    Try something like below:

    sort(outputs('Get_query_results')?['body']['value'], 'Microsoft.VSTS.Common.Priority')

     

    sort_devopsqueryresults.png

     

  • hjoshi4u26 Profile Picture
    on at

    @Expiscornovus it is not working. It showing the error 'Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The action(s) 'Get_query_results' referenced by 'inputs' in action 'Select_2' are not defined in the template.'.'.'

    hjoshi4u26_0-1670386908302.png

    Do we sort the data before mapping the Table or after mapping the Table..?

  • Expiscornovus Profile Picture
    33,876 Most Valuable Professional on at

    Hi @hjoshi4u26,

     

    My guess would be that you renamed/have a different name for your Get Query results action.

     

    In my example my Get query results action name is 'Get query results'.

     

    If in your case it is 'Get query results All Bugs' you would need to update that in the outputs function within the expression:

    sort(outputs('Get_query_results_All_Bugs')?['body']['value'], 'Microsoft.VSTS.Common.Priority')

     

  • hjoshi4u26 Profile Picture
    on at

    LOL 😂 Seem like I made a silly mistake there. Thanks for pointing that out to me 🙂 The solution you provided is working 👍
    Any chance we can sort the data by multiple columns..? In DevOps we can simply do it by holding SHIFT key and then clicking on multiple columns.

  • Expiscornovus Profile Picture
    33,876 Most Valuable Professional on at

    Hi @hjoshi4u26,

     

    With the sort function you are only allowed to sort on one level/key/field, https://aka.ms/logicexpressions#sort

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 474

#2
11manish Profile Picture

11manish 268

#3
David_MA Profile Picture

David_MA 243 Super User 2026 Season 1

Last 30 days Overall leaderboard