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

Notifications

Announcements

Community site session details

Community site session details

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

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

Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,189 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
    93 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,189 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
    93 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,189 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard