The Power Automate Reverse function changes the arrangement of elements in a collection by reversing their order. This operation, when combined with the sorting function, can result in the sorting of items in a descending sequence.
In this article, I’ll introduce you to the reverse function and will provide a step-by-step guide on how to use the function in a Microsoft flow.
Power Automate Reverse Function
Invert the arrangement of elements in a collection. Utilizing this function in combination with sort() enables sorting a collection in descending order.
- collection (mandatory): The collection to be reversed.
- Returns the given collection in reverse order.
Power Automate Reverse Expression Example
reverse(createArray(1,2,3)) => [3,2,1] // reverse expression with variable reverse(variables('myCol'))
How To Use The Power Automate Reverse Function
Follow the steps to use the Power Automate Reverse function in a flow.
Create a new flow with trigger ‘Manually trigger a flow’
Add a new step by clicking on ‘+ New step’
Add a new step
Search for ‘initialize’ and click on ‘Initialize variable’
Add Initialize variable action
Setup Initialize variable: 1) Provide a name, 2) select type Array, 3) Set value to ‘[1,2,3]’
Add a compose step by searching for ‘compose’ and clicking on ‘Compose’
Add Compose action
Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expression’, 3) set expression to ‘reverse(variables(‘myCol’))’ 4) click on ‘OK’
Setup reverse expression in Power Automate
Save and do a test run
Result test run – Power Automate reverse function example