In this “Power Automate CreateArray Function” article, we will learn about what a createArray function is in Power Automate and how to work with the createArray function in Power Automate with real-time project-based examples.
Power Automate, formerly known as Microsoft Flow, is a powerful automation platform that allows you to create workflows and automate various tasks across a wide range of applications and services. One of the key functions in Power Automate is the CreateArray function, which enables you to create arrays, a fundamental data structure used to store and manipulate collections of data. In this article, we’ll explore the CreateArray function in Power Automate and provide real-time examples to demonstrate its practical applications.
Understanding the Power Automate CreateArray Function
The CreateArray function in Power Automate allows you to create an array by specifying the number of elements it should contain. You can use this function to initialize an array with specific values, making it a versatile tool for working with data within your workflows.
The basic syntax of the createArray function is as follows:
createArray(Number of Elements, Initial Value)
- Number of Elements: This is the number of elements you want in your array.
- Initial Value (optional): You can specify an initial value to populate the array. If omitted, the array will be initialized with null values.
Now, let’s dive into some real-time examples to better understand how to use the CreateArray function in Power Automate.

Power Automate CreateArray Function with Real-Time Examples
In this section, we will learn about how to work with the CreateArray function in Power Automate with real-time examples.
CreateArray Function demo with Boolean variable
Let’s create a boolean-type variable and assign the default value to true.
Then, add a compose data operation action and add the below createArray function expression:
createArray('Power Automate',variables('varBoolTest'))

Output:
Once we run the flow, we can see the below output:
[ "Power Automate", true ]
CreateArray Function demo with Integer variable
Let’s create an integer-type variable and assign the default value to 21.
Then, add a compose data operation action and add the below createArray function expression:
createArray('Power Automate', variables('varIntTest'))

Output:
Once we run the flow, we can see the below output:
[ "Power Automate", 21 ]

CreateArray Function demo with Array variable
Let’s create an array-type variable and assign the default as below:
[ "Power ", "Automate" ]
Then, add a compose data operation action and add the below createArray function expression:
createArray('I like',variables('varArrayTest'))

Output:
Once we run the flow, we can see the below output:
[ "I like", [ "Power ", "Automate" ] ]

Create an Array of Objects: CreateArray Function demo with Object variable
Let’s create an object-type variable and assign the default as below:
{ "Name": "John", "Age": 30, "Department": "HR" }
Then, add a compose data operation action and add the below createArray function expression:
createArray(3,variables('varObjectTest'))
Power Automate CreateArray Function Demo with Object variable
Output:
Once we run the flow, we can see the below output:
[ 3, { "Name": "John", "Age": 30, "Department": "HR" } ]

Difference between the “CreateArray” function and the “Append to array variable” action in Power Automate
CreateArray Function:
- Initialization: The “CreateArray” function is used for initializing a new array with a specified number of elements. It’s typically used to create an empty array or an array with null values initially. You can also initialize an array with an optional initial value, which sets the same value for all elements.
- Static Arrays: “CreateArray” is suitable for creating static arrays, where the number of elements is known in advance, and you don’t need to modify the array’s size during the flow’s execution.
- Use Cases: It is handy when you know the exact number of elements you want in your array, and you want to work with a fixed-size array. For example, when you need to set up an array with specific indexes to hold data that will be added later in your flow.
Append to Array Variable Action:
- Appending Data: The “Append to array variable” action is used to add new elements to an existing array variable. It’s ideal when you need to dynamically add data to an array during the execution of your flow.
- Dynamic Arrays: This action is suitable for creating dynamic arrays where the size of the array can change based on the flow’s logic and input.
- Use Cases: Use the “Append to array variable” action when you want to accumulate data over time, such as collecting form responses, gathering user input, or processing items in a loop, and you need to expand the array as new data arrives.
The choice between the “CreateArray” function and the “Append to array variable” action depends on your specific flow requirements:
- CreateArray Function: Use it when you need to initialize a fixed-size array, and you know the number of elements in advance. This is suitable for creating static arrays with a predefined structure.
- Append to Array Variable Action: Use it when you want to dynamically build an array by adding elements during the execution of your flow. This is helpful when dealing with variable-sized collections of data that grow or change as your flow progresses.
Understanding when to use each of these options will help you design more efficient and flexible flows in Power Automate, tailored to your specific needs.
Summary: CreateArray function in Power Automate
See Also: Power Platform Articles
You may also visit the Power Platform article hub, where you will see a bunch of articles focusing on Power Platform, like Power Automate, Power Apps, etc. All the articles are written with real-time project scenarios and troubleshooting techniques. For the Power Automate function references, you may refer to this Microsoft Power Automate Function references article.