How to remove an item from an array in Power Automate? [With 5 examples]

In this Power Automate tutorial, we will see how to remove an item from an array in Power Automate.

Here, I will show different examples related to various topics below:

  • How to remove the last item from an array in Power Automate
  • Remove the first item from an array in Power Automate
  • How to remove a specific item from an array in Power Automate
  • How to remove empty items from an array in Power Automate

Remove an item from an array in Power Automate

Here we will see how to remove the item from an array using Power Automate

To remove the item from an array using Power Automate skip() method.

The skip method in Power Automate is used to remove the items from the front.

Step 1: Log in to Power Automate, and click on +Create -> select the Instant Cloud flow.

Remove an item from an array in Power Automate

Provide the flow name, and select the Manually trigger a flow. Then click on Create.

power automate remove item from array

Now Manually trigger a flow is added to the flow.

How to Remove an item from an array in Power Automate

Step 2: Now, click on the +New step, and select the Initialize variable action. Then provide the below information:

  • Name: provide the name of the variable
  • Type: Select the type as Array
  • Value: Provide the below array
[
  {
    "id": 1,
    "name": "Item 1",
    "price": 10.99
  },
  {
    "id": 2,
    "name": "Item 2",
    "price": 19.99
  },
  {
    "id": 3,
    "name": "Item 3",
    "price": 5.99
  },
  {
    "id": 4,
    "name": "Item 4",
    "price": 7.99
  }
]
Remove an item from an array in Power Automate example

Step 3: Now we will remove the item from an array, so, click on the +New step -> select Compose action. Then provide the below information

  • Inputs: Provide the below expression as an inputs
skip(variables('Array'), 1)
Power automate remove an item from an array

Step 4: Now run the flow manually, you can see the output of compose action, and the first item has been removed.

Power automate remove an item from an array example

This is how to remove an item from an array in Power Automate.

Remove the last item from an array in Power Automate

Here we will see how to remove the last item from an Array using Power Automate

So here we will use the above array, and we will remove the last item from this array using take, length, and add methods.

Here is how we can implement it:

  • First, we will calculate the length of an array using length().
  • Then we will add -1 to the length of the original array using the add method
  • Then we will use the take(), which will take the whole array and extract all items except the last one.

Step 1: In Power Automate, click on +Create and then select Instant cloud flow.

Then provide the flow name and select Manually trigger a flow. Click on Create.

Microsoft power automate remove last item from array

Now Manually trigger a flow is added to the flow page.

power automate remove last item from array

Step 2: Now, click on the +New step, and select the Initialize variable action. Then provide the below information:

  • Name: Provide the name of the variable
  • Type: Select the type as Array
  • Value: Provide the below array
[
  {
    "id": 1,
    "name": "Item 1",
    "price": 10.99
  },
  {
    "id": 2,
    "name": "Item 2",
    "price": 19.99
  },
  {
    "id": 3,
    "name": "Item 3",
    "price": 5.99
  },
  {
    "id": 4,
    "name": "Item 4",
    "price": 7.99
  }
]
Remove the last item from an array in Power Automate

Step 3: Now we will remove the last item from an array, so click on the +New step -> select Compose action. Then provide the below information:

  • Inputs: Provide the below expression:
take(variables('Array'),add(length(variables('Array')),-1))
Remove last item from an array in Power Automate

Step 4: Now run the flow manually, and you can see the result, the last item is removed from an array using Power Automate.

How to Remove the last item from an array in Power Automate

This is how to remove the last element from an array in Power Automate

Remove the first item from an array in Power Automate

Here we will see how to remove the first 2 items from an array using Power Automate.

For example, we have an array [1,2,3,4] so, we will create a flow that will reverse the array [4,3,2,1] and then remove the last 2 items i.e. 2, 1. Then it will return [4,3], and after that, we will reverse the result array and the final output is [3,4]

Step 1: Now, create an instant cloud flow, then provide the flow name and select manually trigger a flow. Then click on Create.

power automate remove first item from array

Now you can see Manually trigger a flow is added to the page.

power automate remove first item from array

Step 2: Next click on the +new step -> select Initialize variable action. Then provide the below information:

  • Name: Provide the name of the variable
  • Type: Select the type as Array
  • Value: Provide the below array
[
  {
    "id": 1,
    "name": "Item 1",
    "price": 10.99
  },
  {
    "id": 2,
    "name": "Item 2",
    "price": 19.99
  },
  {
    "id": 3,
    "name": "Item 3",
    "price": 5.99
  },
  {
    "id": 4,
    "name": "Item 4",
    "price": 7.99
  }
]
Remove the first item from an array in Power Automate

Step 3: Next click on the +New step -> select Compose action -> then provide the below information.

  • Inputs: Provide the below expression
reverse(variables('Array'))

Similarly, create two more compose action, and then provide the information as Inputs.

Compose -remove the item

take(outputs('Compose_-reverse_the_array'),add(length(outputs('Compose_-reverse_the_array')),-1))

Compose – result

reverse(outputs('Compose-_remove_the_item'))
Remove first item from an array in Power Automate

Step 4: Now test the flow manually and you can see the result, first 2 items is removed from an array using Power Automate.

Remove the first item from an array in Power Automate example

This is how to remove the first item from an array in Power Automate.

Remove a specific item from an array in Power Automate

Here we will see how to remove specific items from an array of objects using Power Automate.

For example, we have array [1,2,3,4], so here we will create a flow that will remove 2 from an array and return [1,3,4] in Power Automate.

Step 1: Create an Instant cloud flow, then provide the flow name and select Manually trigger a flow in Power Automate. Then click on Create

power automate remove specific item from array

Now Manually trigger a flow action is added to the flow page.

Remove a specific item from an array in Power Automate

Step 2: Now, click on the +New step -> select Initialize variable action. Then provide the below information:

  • Name: Provide the name of the variable
  • Type: Select the type as Array
  • Value: Provide the below array
[
  {
    "id": 1,
    "name": "Item 1",
    "price": 10.99
  },
  {
    "id": 2,
    "name": "Item 2",
    "price": 19.99
  },
  {
    "id": 3,
    "name": "Item 3",
    "price": 5.99
  },
  {
    "id": 4,
    "name": "Item 4",
    "price": 7.99
  }
]
Remove a specific item from an array in Power Automate example

Step 3: Now we will remove the specific item, so, click on the +New step -> select Filter array action. Then provide the below information:

  • From: Select the array variable from dynamic content.
  • Choose a value: Provide the below expression:
@item()['id']
  • Operator: Select the operator as is not equal to
  • Choose a value: Provide the value as empty like the below screenshot.
How to Remove a specific item from an array in Power Automate

Step 4: Now test the flow manually, and you can see the result, that id =2 is removed from the array.

Remove a specific item from an array in Power Automate

This is how to remove a specific item from an array in Power Automate.

Remove empty items from an array in Power Automate

Here we will see how to remove empty items from an array of objects using Power Automate.

In this example, we will use the array of objects and we need to remove the items whose price value is empty.

Step 1: In Power Automate, select Instant cloud flow. Then provide the flow name, and select ‘Manually trigger a flow’. Then click on Create.

Microsoft power automate remove empty item from an array

Now Manually trigger a flow is added to the flow page.

Remove empty items from an array in Power Automate

Step 2: Then click on the +New step and select Initialize variable action. Then provide the below information:

  • Name: Provide the name of the variable
  • Type: Select the type as Array
  • Value: Provide the below array
[
  {
    "id": 1,
    "name": "Item 1",
    "price": ""
  },
  {
    "id": 2,
    "name": "Item 2",
    "price": 19.99
  },
  {
    "id": 3,
    "name": "Item 3",
    "price": ""
  },
  {
    "id": 4,
    "name": "Item 4",
    "price": 7.99
  }
]
Microsoft power automate remove empty item from array

Step 3: Next we will remove the item whose price column is empty, so click on the +New step -> select Filter array action. Then provide the below information:

  • From: Select the array variable from dynamic content.
  • Choose a value: Provide the below expression:
item()['price']
  • Operator: Select the operator as is not equal to
  • Choose a value: provide the value as empty like the below screenshot.
power automate remove empty items from array

Step 4: Now run the flow manually, and you can see the items removed, whose price value is empty.

How to Remove empty items from an array in Power Automate

This is how to remove an empty item from an array using Power Automate.

Conclusion

In this Power Automate tutorial, we saw how to remove items from an array using Power Automate. Also, we cover 5 different examples. These are:

  • Power Automate remove the item from an array
  • Power Automate remove the last item from an array
  • Power Automate remove the first item from an array
  • Power Automate remove a specific item from an array
  • Power Automate remove the empty item from an array

You may also like:

>