Power Automate Remove Item from Array

Recently, I was working on a project where I got a requirement to remove items from an array within the Power Automate.

In this tutorial, I will explain how to remove the first element from an array in Power Automate and then move on to removing the last item.

Next, I will discuss how to eliminate an array’s specific element and empty element with the help of Power Automate.

Power Automate Remove First Item from an Array

Now, I will show you an example of how to remove the first element from an array using Power Automate.

Example

InputOutput
[“Alaska”, “Arkansas”, “California”, “Colorado”, “Florida”][“Arkansas”, “California”, “Colorado”, “Florida”]

Follow the given steps:

1. Create a Power Automate Instant cloud flow. Navigate to the Power Automate Home page and click + Create -> select Instant Cloud Flow. Give flow name, and select trigger Manually trigger a flow-> Tap Create button.

2. Initialize the array values by taking an ‘Initialize variable‘ flow action. Set the required details:

  • Name – Enter the variable name
  • Type – Choose the variable type as array
  • Value – In the value section, pass the below array of values
["Alaska", "Arkansas", "California", "Colorado", "Florida"]
How to remove an element from an array using Power Automate

3. Add a Compose flow action to remove the first item from an array using the Power Automate skip() function.

Inputs: Click Expression -> Insert the code below.

skip(variables('United States'),1)
Power Automate remove first item from array

4. Once the flow is ready, Click on Save. Then, Test the flow. In the Runflow window, select the Manually radio button. Click on Runflow.

5. The image below will show the output after removing the first item from an array.

Removing first item from an array using Power Automate

How to Remove the Last Item of an Array in Power Automate

Now, let’s check the second example of removing the last element from an array with Power Automate.

Change the expression in the Compose flow action to remove the last item from an array.

Example

InputOutput
[“Alaska”, “Arkansas”, “California”, “Colorado”, “Florida”][“Alaska”, “Arkansas”, “California”, “Colorado”]

1. In the Compose Inputs, add the below given expression:

reverse(skip(reverse(variables('United States')),1))
How to remove last item of an array in Power Automate

Then, save and run the flow manually.

2. The output displays the removal of the last element from an array, as shown below:

Removing last item from an array using Power Automate

This is how to remove the last item from an array by using the reverse() and skip() functions in Power Automate.

Removing Specific Element from an Array in Power Automate

Here, we will see how to remove a specific item from an array variable using Power Automate.

I will follow the same example with the same variable values.

Example:

In the array below, I am required to remove 3rd item [“California”] from the list.

Input Output
[“Alaska”, “Arkansas”, “California”, “Colorado”, “Florida”][“Alaska”, “Arkansas”, “Colorado”, “Florida”]

1. Add a ‘Filter array‘ flow action under the Initialize variable. Configure the details below:

  • From: Apply filter on initialize variable. Take the variable from dynamic content.
  • Filter Query: Add the expression as given in the code below.
California  is not equal to item()
Item ValueOperatorItem
Californiais not equal toitem()
How to remove specific item of an array in Power Automate

2. To view the result, add a Compose flow action.

  • Inputs: Take the Body of the filter array from dynamic content.
How to remove specific element of an array in Power Automate

Output:

Removing specific item from an array using Power Automate

This is how to remove a specific element from an array using Power Automate.

Power Automate Remove Empty Item from an Array

In the same way, I will demonstrate an example of how to remove an empty element from an array using Power Automate.

Example

Input Output
[“Alaska”, “Arkansas”, “”, “Colorado”, “Florida”][“Alaska”, “Arkansas”, “Colorado”, “Florida”]

Follow all the above-mentioned instructions.

1. In the Filter array flow action, change the filter query condition as shown below:

  • From: Take the initialized variable from the dynamic content.
  • Filter Query: Give the below code.
@equals(@{empty(item())},false)
How to remove empty item from an array using Power Automate

Output:

Removing empty item from an array in Power Automate
Power Automate remove empty element from array

Conclusion

You can easily remove an item from an array using the Power Automate skip() function. I hope you understand how to remove elements from an array using Power Automate.

Here, I have covered different examples:

  • Removing the first element from an array
  • How to remove the last item from an array
  • How to eliminate the specific item of an array
  • Removing an empty item from an array

You may also like the following tutorials:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…