Create Array Function in Power Automate

Introduction

In Power Automate, at times we need to merge 2 different strings into an Array we can use Create Array Function so that we can get easily desired result. As an example, let us see how to get an array of emails with 2 strings as well as the process to merge two different arrays of questions and answers into a single array.

Step 1

Login to the required Power Apps environment using URL make.powerapps.com by providing username and password and click on Flows on the left-hand side as shown in the below figure.

Usage of Create Array Function in Power Automate

Step 2

After Step 1, Click on New Flow and select instant cloud flow and provide the trigger as Manually trigger a flow and click on Create as shown in the below figure.

Usage of Create Array Function in Power Automate

Step 3

After Step 2, name flow as Create Array and take initialize variable and name it as Set Email of 1st person with the following fields,

Name : Person 1 Email
Type : String
Value : [email protected]

as shown in the below figure.

Usage of Create Array Function in Power Automate

Step 4

After Step 3, take another parallel branch with initialize variable and name it as Set Email of 2nd Person with the following fields,

Name : Person 2 Email
Type : String
Value : [email protected]

as shown in the below figure.

Usage of Create Array Function in Power Automate

Step 5

After Step 4, take compose action and name it as Create an Array of email strings with Create Array Function and provide input as CreateArray with the following syntax

createArray(object_1: any, ...)

and provide the value as

createArray(variables('Person 1 Email'),variables('Person 2 email'))

and click on ok /Update as shown in the below figure.

Usage of Create Array Function in Power Automate

Step 6

After Step 5, and take initialize variable and name it as Set Array of Questions with the following fields

Name : 1st Set of Questions
Type : Array
Value : [1,2,3,4,5,6]

as shown in the below figure.

Usage of Create Array Function in Power Automate

Step 7

After Step 6, and take initialize variable and name it as Set Array of Answers with the following fields

Name : Answers for the 1st Set of Questions
Type : Array
Value : [1,2,3,4,5,2]

as shown in the below figure.

Usage of Create Array Function in Power Automate

Step 8

After Step 7, and take compose variable and name it as Create an Array of Arrays of Questions And Answers with Create Array Function and provide input

createArray(variables('1st Set of Questions'),variables('Answers for the 1st Set of Questions'))

 and click on ok / update as shown in the below figure.

Usage of Create Array Function in Power Automate

Step 9

After Step 8, click on save and test the flow and observe results as shown in the figure.

Usage of Create Array Function in Power Automate

Note

  1. Make sure to save and run the flow whenever you try expressions.
  2. MS documentation is found here

Conclusion

In this way, we can easily create an array with a combination of 2 strings and an array of integers with Create Array Function to achieve simple requirements in Power Automate flow.


Similar Articles