Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Sort by Priority in Power Automate

(0) ShareShare
ReportReport
Posted on by 93

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

  • Expiscornovus Profile Picture
    32,155 Most Valuable Professional on at
    Re: Sort by Priority in Power Automate

    Hi @hjoshi4u26,

     

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

  • hjoshi4u26 Profile Picture
    93 on at
    Re: Sort by Priority in Power Automate

    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
    32,155 Most Valuable Professional on at
    Re: Sort by Priority in Power Automate

    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
    93 on at
    Re: Sort by Priority in Power Automate

    @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..?

  • Verified answer
    Expiscornovus Profile Picture
    32,155 Most Valuable Professional on at
    Re: Sort by Priority in Power Automate

    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

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1