How to Clear an Array Variable in Power Automate

Do you need to clear an array variable in Power Automate?

Variables are an essential feature that allows you to store and update values during the run time of your flow.

When utilizing a loop in Power Automate, storing values with an array variable is a practical way to keep track of each iteration. Once the loop concludes, you may want to use the results stored within the array for further actions in your flow.

However, you may also have the need to use the array for a different task within the same flow. For this, you will likely want to clear the array variable to be sure it’s empty before each use.

This article will show you how to reset an array variable and clear out any previous items stored in the array.

Initialize Array Variable

Clearing out an array will only work with an array variable. Other types of arrays you can create such as within a Compose action, can’t be cleared out.

You will first need to initialize an array variable using the Initialize variable action.

  1. Add the Initialize variable action to your flow.
  2. Give your variable a Name. This will be used to reference the variable later on in your flow when adding or updating items in the array.
  3. Select Array from the Type dropdown list to create an array type variable.
  4. Leave the Value field blank. This will create an empty array.

You can now use the initialized array variable to store and manage values in your flow.

Append to Array Variable In For Each Loop

It’s likely you will be using your array variable inside a For each loop.

You can use the Append to array variable action inside your to add items to your flow during each loop iteration.

  1. Add the Append to array variable action to your loop.
  2. Select the Name of your array variable that you previously initialized.
  3. Add the item you want to add to the array in the Value field.

You can also use the Append to array variable action outside of a loop, but this will only allow you to add one item to your array.

Now that you have some values in your array, you can remove them and reuse the array as if it were new!

Set Variable Action Outside Loop to Clear Array

To clear an array, you can use the Set variable action. This will ensure that the array is emptied. Here is the approach to use.

  1. Add the Set variable action to your flow whenever you want to clear the array. This might be outside your loop depending on your requirements.
  2. Select the Name of your array from the dropdown list.
  3. Set the Value of the variable to []. This is an empty array or an array with no items.

This assigns an empty value to the array variable and effectively clears the array, removing all elements in it and initializing the variable with an empty array.


This article has shown you how to initialize your array variable, add items to it in a loop, and then clear the array.

This knowledge allows you to effectively manage your arrays, ensuring that you can reuse array variables in your flows.

To clear any array variable, you can use the Set variable action and set the value to an empty array.

Did you know how to clear the items from your array variables? Let me know in the comments!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles



Submit a Comment

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

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!