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:
Output as shown below:
(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
Hi @hjoshi4u26,
With the sort function you are only allowed to sort on one level/key/field, https://aka.ms/logicexpressions#sort
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.
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')
@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.'.'.'
Do we sort the data before mapping the Table or after mapping the Table..?
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')
Michael E. Gernaey
497
Super User 2025 Season 1
David_MA
436
Super User 2025 Season 1
Riyaz_riz11
244
Super User 2025 Season 1