Power Automate Reverse Function Explained

Power Automate Reverse Function

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

Power Automate Reverse expression
reverse expression in Power Automate

Invert the arrangement of elements in a collection. Utilizing this function in combination with sort() enables sorting a collection in descending order.

Syntax

reverse([<collection>])

Input parameters

  • collection (mandatory): The collection to be reversed.

Return value

  • 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.

  1. Create a new flow with trigger ‘Manually trigger a flow’

    Power Automate Reverse Function new flow

    New flow

  2. Add a new step by clicking on ‘+ New step’

    Power Automate Reverse Function new step

    Add a new step

  3. Search for ‘initialize’ and click on ‘Initialize variable’

    Power Automate Reverse Function add initialize variable

    Add Initialize variable action

  4. Setup Initialize variable: 1) Provide a name, 2) select type Array, 3) Set value to ‘[1,2,3]’

    Power Automate Reverse Function setup initialize variable

    Setup variable

  5. Add a compose step by searching for ‘compose’ and clicking on ‘Compose’

    Power Automate Reverse Function add compose

    Add Compose action

  6. Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expression’, 3) set expression to ‘reverse(variables(‘myCol’))’ 4) click on ‘OK’

    Power Automate Reverse

    Setup reverse expression in Power Automate

  7. Save and do a test run

    Power Automate Reverse Function test run result

    Result test run – Power Automate reverse function example

Leave a Comment

Your email address will not be published. Required fields are marked *