How to Reverse an Array in Power Automate?

Are you working in arrays in Power Automate? You might get a requirement to reverse an array in Power Automate.

Power Automate has a collection function called the reverse() function that changes the arrangement of elements of an array in reverse order.

In this tutorial, I will explain how to reverse an array using Power Automate Instant cloud flow. Also, I will show reversing an array of items from the SharePoint list column with the help of Power Automate.

Power Automate reverse() function

The reverse() function in Power Automate converts the order of items in a collection to a reversing manner.

The Power Automate reverse() function output will be the updated collection in reverse order.

InputOutput
Lidia, Jhon, RoseRose, Jhon, Lidia

Power Automate Reverse an Array [Examples]

Now, let’s begin with implementing the examples of how to reverse items from an array using Power Automate cloud flow.

Dig in to know more!

Example 1:- [Using Power Automate Instant cloud flow]

InputOutput
Power Automate, Power BI, Power AppsPower Apps, Power BI, Power Automate

Follow the below-mentioned steps:

1. Open the Power Automate Home page -> click on + Create -> Select the Instant cloud flow -> Provide the flow name and choose the flow trigger (Manually trigger a flow) -> Click on the Create button.

2. Take an Initialize Variable flow action to create an array of elements. Configure the below details:

  • Name: Enter a name for the variable.
  • Type: Select variable type as ‘Array‘.
  • Value: Insert the below expression here.
createArray('Power Automate','Power BI','Power Apps')

You can replace the elements with the elements you need.

How to reverse an array in Power Automate

3. Next, add a Compose flow action to reverse the created array.

See also  How to Check Condition Contains String in Power Automate?

Inputs: Click on Expression -> Insert the below code.

reverse(variables('Power Platform'))
Reverse an array using Power Automate

4. The flow is ready now. Click on Save. Test it Manually. Select the Runflow button.

5. The screenshot below represents the reverse order of an array’s elements in compose flow action.

How to reverse a string array in Power Automate

This is how to reverse an array in the Power Automate flow using the reverse() function.

Example 2:- [Reverse SharePoint List column items]

In this example, I will show you how to reverse an array of SharePoint list column item values using a Power Automate flow.

Scenario:

Suppose I have taken a SharePoint list [Leave Request] with a set of names in a list column[Employee Name], as shown below.

I wanted to reverse the Employee Name column values.

Power Automate reverse array items

Below are the steps to do this example:

1. Create an Instant cloud flow in Power Automate.

2. Then, add the ‘Get Items‘ flow action to retrieve all the SharePoint list items. Fill in the required details:

  • Site Address: Provide a SharePoint site.
  • List Name: Choose a SharePoint list from the drop-down.
How to reverse items from an array using Power Automate

3. Take the Initialize Variable flow action. Provide a Name and select the data type as ‘Array‘.

How to reverse items from an array with Power Automate

4. Next, add Append to array variable flow action to append the list column values in an array.

Configure the details given below:

  • Name: Select the variable name from the drop-down.
  • Value: Take the Employee Name from dynamic content.

Then, For each loop will be added automatically.

Reverse an array using Power Automate flow

5. After that, add a Compose flow action to reverse the list column values. Provide the below expressions in the Inputs section.

reverse(variables('Employee Name'))
Reverse an array from a given position in Power Automate

6. Once the Power Automate flow is ready, save and run the flow manually.

See also  How to get days of month in Power Automate + 15 Examples

7. If there is no error, the flow runs successfully. Now, open the compose flow action to check the output.

It will show the reversing order of an array element [Employee Names].

Reverse an array with Power Automate reverse() expression

This is all about reversing an array of items with the Power Automate reverse() expression.

Conclusion

I trust this tutorial gave you a clear view of reversing an array of elements using the Power Automate reverse() function.

I have covered the two examples, such as:

  • Inverting an array in Power Automate [Manually]
  • Example of how to reverse SharePoint list column items in Power Automate

You may also like:

>