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.
Input | Output |
Lidia, Jhon, Rose | Rose, 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]
Input | Output |
Power Automate, Power BI, Power Apps | Power 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.
3. Next, add a Compose flow action to reverse the created array.
Inputs: Click on Expression -> Insert the below code.
reverse(variables('Power Platform'))
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.
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.
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.
3. Take the Initialize Variable flow action. Provide a Name and select the data type as ‘Array‘.
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.
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'))
6. Once the Power Automate flow is ready, save and run the flow manually.
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].
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:
- How to remove an item from an array in Power Automate?
- Convert an Array to a String in Power Automate
- Get Unique Values from an Array in Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.