How to Initialize Array Variable in Power Automate

In this Power Automate tutorial, we will learn what is Power Automate Array Variable and how to initialize Array Variable in Power Automate with different examples.

Moreover, we will also learn the below-related topics:

  • Power Automate initialize Array Variable
  • Power Automate initialize Array Variable json
  • Power Automate initialize Array Variable of objects
  • Power Automate initialize Array Variable function
  • Power Automate append to an array variable
  • Power Automate initialize variable array of empty
  • Power Automate initialize an array with multiple values

Also, Read: What is Initialize Variable in Power Automate

Array Variable in Power Automate

  • The same data type array can be used with the Power Automate Array data type, and the values must follow the array format.
  • For example, if it is an integer array then the array values will be [1,2,3..] no need of a double quote mark.
  • In the same way, if it is of string array then the array looks like [“a”, “b”, “c”..] within a double quote mark.
  • And for the dynamic content of array item values no need for a double quote mark, even if it is a string value.

Check: How to Use Power Automate Delay Action

Power Automate initialize Array Variable

Here we will see how to initialize the variable with the Array data type in Power Automate.

In this example, we will initialize the string array to display the TaskName, TaskPriority, and Status values in the array format. Follow the below steps:

Step:1

  • Once the Power Automated cloud flow has been created, select an action to initialize the variable in an array format as displayed below:
  • Enter the name and type of the variable as an array and in the values field add the dynamic content values.
Power Automate initialize the variable array
Power Automate initialize the variable array

Step:2

After initializing the array variable, add a compose action to retrieve the array data values from the SharePoint list on Power Automate.

Power Automate initialize variable array example
Power Automate initialize variable array example
  • To run the Power Automate flow, select the Test option and choose Manually and click the Save & Test option.
  • Once the Power automation flow is triggered and runs, we can see the array of data values from the SharePoint list in the compose output section as below:
An example of Power Automate initialize variable array
An example of Power Automate initialize Array Variable

This is how to initialize the variable with the Array data type in Power Automate.

Check out: How to Initialize Boolean Variable in Power Automate

Power Automate initialize Array Variable of JSON

Let us see how we can initialize the Array Variable of JSON in Power Automate flow,

Before following the steps, we should know the syntax of the JSON format:

JSON data is known as name/value pairs. And the name/value pair consists of a field name in double quotes, followed by a colon, followed by a value. The below syntax code is an example of JSON format.

"name":"John"

Follow the below steps to initialize variable array of JSON

In this example, we will pass the username and user email as dynamic input content in the array-type format. In the compose action we will see the encoded values of the username and user email of the person who triggered the flow in Power Automate.

Step:1

Open the Power Automate and create an instant flow by selecting the manual trigger as displayed below:

Power Automate initialize variable array of JSON
Power Automate initialize variable array of JSON

Step:2

  • Select an action to initialize the variable in an array-type format as displayed below:
  • Enter the variable name and then select the type of the variable as an array.
  • And in the values field add the JSON format data values by choosing the dynamic content values. Here we are passing two values inside the array with a JSON format.

[ {“name”:@{triggerOutputs()[‘headers’][‘x-ms-user-name-encoded’]}} , {“email”:@{triggerOutputs()[‘headers’][‘x-ms-user-email-encoded’]}}]

Where, (JSON key-value pairs)

  1. name and email = (JSON Keys)
  2. user-name and user-email = dynamic content values (JSON Value)
An example of Power Automate initialize variable array of JSON
An example of Power Automate initialize variable array of JSON

Step:3

  • After initializing the array variable, add a compose action to retrieve the array data values from the initialized variable on Power Automate.
  • Click the Save & Test -> option to save and test the Power Automate flow.
Power Automate initialize variable array of JSON example
Power Automate initialize variable array of JSON example

Step:4

  • Choose Manually under the test option and select Run Flow. Once the Power automation flow is triggered and runs.
  • We can see the output in Compose action below, where the user name and user email are in the encoded value inside the Array in a JSON format.
Initialize variable array of JSON in Power Automate
Initialize variable array of JSON in Power Automate

This is how to initialize variable array of JSON in Power Automate flow.

Have a look: How to Initialize Float Variable in Power Automate

Power Automate initialize Array Variable of objects

Here we will see how to initialize Array Variable of objects using Power Automate.

Here we will initialize a variable and then create an array, where each item in the array has an object with its properties. We will unite the two arrays of objects.

  • Once the Power Automated instant flow has been created, select an action to initialize the variable in an array format as displayed below:
  • In this example, we will initialize two variables and select the variable type as an array. In the values section, add the array of object items.
Power Automate initialize variable array of objects
Power Automate initialize variable array of objects
  • Now we will unite the two arrays of objects using the Union function to get the array items in a single array object.
  • So click on the Next step and select compose action and in input write the below expression:
union(variables('VarArray'),variables('VarArray2'))
Power Automate initialize variable array of objects example
Power Automate initialize variable array of objects example
  • Now click on Save and run the flow manually, we can see the result in the compose action output.
An example of Power Automate initialize variable array of objects
An example of Power Automate initialize variable array of objects

This is how to initialize variable array of objects using Power Automate.

Power Automate initialize Array Variable function

Let us see how we can create an array function with the initialized variable in Power Automate.

Once the Power Automated instant flow has been created, select an action to initialize the variable in an array format using the create Array function as displayed below:

createArray('SharePoint','Power BI','Power Automate')

Where,

  1. CreateArray = Function Name
  2. SharePoint, Power BI, Power Automate = Array items
Power Automate initialize variable array function
Power Automate initialize variable array function
  • Add a compose action to see the output for the initialized variable in an array format.
  • Click save to save the Power Automate flow.
Power Automate initialize variable array function example
Power Automate initialize variable array function example

To test the flow, select Test Flow -> Manually -> Run Flow. Once the Power automation flow is triggered and runs. We can see the output in Compose action below:

Example of Power Automate initialize variable array function
Example of Power Automate initialize variable array function

This is how to create an array function with the initialized variable in Power Automate.

Check Post: How to Initialize Object Variable in Power Automate

Power Automate append to an array variable

Here we will see how we can append to an array variable in Power Automate,

In the Previous heading, you can see that we have created an array using the CreateArray function and initialized a variable. So now we will see how to append an array item to the existing created array variable.

In the below screenshot, you can see that the array variable has been created.

Power Automate append to an array variable
Power Automate append to an array variable
  • Now we will add or append the array value to the existing array variable using the Append to array variable action.
  • For that, Simply +New step and choose Append to array variable action. And then in the Name section select the existing array variable that we created and in the Value section add the values that you want to append to the existing variable.
  • Here, I am going to append the PowerApps as an array value with the existing array variable.
Power Automate append to an array variable example
Power Automate append to an array variable example

Select +Newstep -> Compose action to see the output of the initialized variable.

append to an array variable in Power Automate
append to an array variable in Power Automate

Now click on Save&Test and run the flow manually, we can see the result in the compose action output.

append to an array variable in Power Automate
append to an array variable in Power Automate

This is how to append to an array variable in Power Automate.

Power Automate initialize Array Variable of empty

Let us see how we can initialize Array Variable of empty in Power Automate,

  • Once the Power Automated instant flow has been created, select an action to initialize the variable in an array format.
  • Enter the name and type of the variable as an array and in the values field add an empty array as [] as highlighted below:
Power Automate initialize variable array of empty
Power Automate initialize variable array of empty

Add a compose action, to see the output for the initialized variable in Power Autome. Click Save to save the flow:

Power Automate initialize variable array of empty example
Power Automate initialize variable array of empty example
  • Once the Power Automate flow has run, in the compose action we can see it displays a link Click to download instead of showing on compose’s output.
  • So when we click on the click to download option, it displays
Example of Power Automate initialize variable array of empty
Example of Power Automate initialize variable array of empty

This is how we can initialize variable array of empty in Power Automate flow.

Read Post: How to Initialize Integer Variable in Power Automate

Power Automate initialize an array with multiple values

Here we will see how we can initialize an array with multiple values using the Power Automate flow.

  • Once the Power Automated instant flow has been created, select an action to initialize the variable in an array format as displayed below:
  • Enter the name and type of the variable as an array and in the values field add the multiple values in it.
Power Automate initialize an array with multiple values
Power Automate initialize an array with multiple values
  • After initializing the array variable, add a compose action to retrieve the array data multiple values from the initialized variable on Power Automate.
Power Automate initialize an array with multiple values example
Power Automate initialize an array with multiple values example
  • To see the output for the initialized variable in Power Autome. Click Save to save the flow and test -> Manually Test -> Run Flow
Run Power Automate Flow
Run Power Automate Flow
  • In the below screenshot, you can see that compose action displays the array data with multiple values.
Example of Power Automate initialize an array with multiple values
Example of Power Automate initialize an array with multiple values

This is how to initialize an array with multiple values using the Power Automate flow.

Moreover, you may like some more Power Automate and SharePoint tutorials:

In this Power Automate tutorial, we have learned what is Power Automate Array Variable and how to initialize a variable for an Array data type in Power Automate with different examples.

Moreover, we also learned the below-related topics:

  • Power Automate initialize Array Variable
  • Power Automate initialize variable array json
  • Power Automate initialize variable array of objects
  • Power Automate initialize Array Variable of empty