In this Power automate tutorial, we will learn about power automate array variable. And also we will discuss the below points:
- Power automate array variable apply to each
- Power automate array variable to string
- Power automate array variable index
- Power automate create array variable
- Power automate variable array of objects
- Power automate append array variable
- Power automate add array variable
- Power automate append to array variable json
- Power automate filter array variable
- Power automate remove duplicates from array variable
- Power automate email array variable
- Power automate get array variable
- Power automate get item from array variable
- Power automate get first item in array variable
- Power automate length of array variable
Power Automate array variable apply to each
Here we will see how to loop the array using applying it to each item in an array in the Power Automate.
So here we will create a list of arrays in power automate and then add apply to each control action to loop through the array. At last, store the list of items from an array to the SharePoint list.
So here I have created a Technology list in SharePoint having one column where we will store the Technology name. like below:
Next in Power Automate, create a Manually triggered Flow. Then click on the Next step.
Select the Initialize variable, and set the variable name, type as an array, and set the value like the below array.
Now we will loop through each item in an array using Apply to each loop. So, click on the Next step, and select Apply to each action. Then in the value set the varArray from the dynamic content.
Now we will create the array of items in the SharePoint list, so click on the Add an action inside the loop and select Create item.
Then provide the site address, list name, and in title select the current item of the Apply to each from the dynamic content.
Next, click on Save and run the Flow manually, once your flow ran successfully
After the flow ran successfully, go to the SharePoint list, you can see loop control create an item from the array to the list.
This is an example of a Power Automate array variable apply to each.
Power automate array variable to string
Here we will see how to convert array variables to string using Microsoft Flow.
We will use the Join action in Power automate to convert the array into strings.
In Power Automate, select the Manually triggered Flow, and then click on Next step.
Select the Initialize variable action, then set the variable name, type as an array, and set the values like below array
Now we will convert the array into a string, so click on the Next step and select Join action from the data operation. In the From field set the varArray from the dynamic content, and then in Join with box set the comma ‘,’.
Next, click on Save and run the flow manually, we can see the result in the join output.
This is an example of the Power automate array variable to string.
Power automate array variable index
Here we will see how to access elements by index value from the array variable in Microsoft Flow.
For example, we have a list such as [“SharePoint”, “Power Automate”, “Power Apps”]. So in the array, the index value starts from 0, to get the value Power Automate we can write varArray[1].
So, In the Power Automate, create a Manually triggered Flow. Then click on the Next step.
Select the Initialize variable, and then set the variable name, type as an array, and set the value like below.
Then click on Next step and select Compose action. Then in Input add the below expression:
variables('varArray')[1]
Now click on Save and run the flow manually, you can see the result in the compose output.
This is a quick example of a Power Automate array variable index.
Power automate create array variable
Here we will see how to use the createArray function to create the array in Power Automate.
In Power automate, click on Manually triggered Flow. Then click on the Next step.
Select Initialize variable action, and then set the variable name, type as Array, and value like below.
Now we will create an array with the provided array using the createArray function in Power automate. And createArray function always creates a new array even if we provide an array as one of the objects.
Click on the Next step and then select Compose action. In the input write the below expression:
createArray(variables('varArray'),'Power Bi')
Now click on Save and run the Flow manually. We can see the result in the compose output.
This is how to create array variable in Power Automate.
Power automate variable array of objects
Here we will see how to compare an array of objects based on array item property using Power Automate.
Here we will create an array, where each item in the array has an object with its properties. We will compare the two arrays of objects and then filter the common objects.
So, In the Power automate select the manually triggered flow. Then click on the Next step.
Select the Initialize variable action, and then set the variable name and type as an array and set the value like below.
Similarly, initialize another variable of type array and set the value.
Now we will compare the two arrays of objects using the intersection function to get the common object.
So click on the Next step and select compose action. and in input write the below expression:
intersection(variables('varArray1'),variables('varArray2'))
Now click on Save and run the flow manually, we can see the result in the compose output.
This is an example of Power automate variable array of objects.
Power automate append array variable
Here we will see how to append value in the array variable using Microsoft Flow.
Now we will create a flow in which we will create an array and then we will append the value at the end of the array using Microsoft Flow.
In the Power Automate, create a Manually triggered Flow. Then click on the Next step.
Select Initialize variable action, then set the variable name, type as an array, and set the value like below.
To append a value to the array, click on the Next step and then select the ‘Append to array variable‘ action. Then in the variable name select the variable from the dropdown and then add the value.
Next, to see the result we will use the compose, so click on the next step and select the Compose action, then in the input box set the varArray1 from the dynamic content.
Now click on Save and run the Flow manually, we can see the result in the compose output.
This is how to append an array variable in Power Automate.
Power automate add array variable
Here we will see how to add properties to the array variable using Microsoft Flow.
So we will fetch a list of items from the SharePoint list called Technology, then we will add a property to the array of items using Microsoft Flow.
So, in the Power Automate, create a manually triggered Flow. And click on the Next step.
Now we will fetch the list of items from the Technology list in SharePoint. So, select the Get items action. Then Provide the site address and list name.
Now we will create a compose action that will take input of a list of items, later we will use it as an array.
So, click on the Next step, and then select compose action. In input add the value of get items from the dynamic content.
Now click on the Next step, and then select initialize variable action. Then set the variable name, type as an array, and in value add the output of the compose.
Next, we will create an Apply to each that will loop through each item in the array we have initialized.
So click on the Next step, and then select Apply to each action. In the value set the array, like the below screenshot.
Now we will add property value to the array, so click on the Next step and then select the compose action. In input add the below expression:
addProperty(item(),'Company', 'Test')
Now run the flow manually, and you can see the property value pair at the end of the array.
This is how to add array variable in Power Automate.
Power automate append to array variable JSON
Here we will see how to append to array variable JSON using Microsoft Flow.
So, we will create a flow in which we will append an array to the array of objects.
Now in the Power Automate select the Manually triggered Flow. Then click on the Next step.
Select the Initialize variable action, then set the variable name, type as an array, and set the value like below:
Now we will append the array to the array variable. So click on the next step and select Append to array variable action.
Then choose the variable name from the dropdown, and in value write the array like below:
Next, we will create a compose action to see the result, so click on the next step and select compose action. Then in input add the varArray from the dynamic content.
Now click on Save and run the Flow manually. Now we can see the result in the compose output.
Check out, Microsoft flow examples: Save Office 365 email attachments to OneDrive for Business
Power automate filter array variable
Here we will see how to filter items from the array in Microsoft Flow.
To filter an Array we will use the Filter Array action, which will go through an array and returns a new array by filtering.
So, in Power Automate click on the Manually Triggered Flow. Then click on the Next step.
Now, select the Initialize variable action and set the variable name, type as an array, and set the value like below.
Now we will filter out the name whose age is 28, so click on the Next step and select Filter Array action.
Then set the From with the variable from the dynamic content and in value write the below expression equal to 28.
item()['Age']
Now click on Save and run the flow manually. We can see the result of the name whose age is 28.
This is how to filter array variables in Power Automate.
Power automate remove duplicates from an array variable
Here we will see how to remove duplicate values from an array variable using Power Automate.
In Power Automate, select the Manually triggered Flow. Then click on the Next step.
Select the Initialize variable action and set the variable name, type as an array, and set value like below array:
Now we will remove the duplicate item from the above array by using the Union function.
So, click on the Next step and select Compose action. In input write the below expression.
Union(variables('varArray'),variables('varArray'))
Now click on save and run the Flow, we can see the result after removing the duplicate values out of 5 values, 3 values left.
This is how to remove duplicates from an array variable using power automate.
Power automate email array variable
Here we will see how to send array in an email using Power automate.
To send an array of items through email, we need to covert the array variable to string, to use in send email using Power Automate.
In Power Automate, select the Manually triggered flow. Then click on the Next step.
Select the Initialize variable action, and then set the variable name, type as array, and set the value like below array.
Now we will convert the array into string which we will use later in email.
So, click on the Next step and select Join action from data operation. Then in From set the array variable and in join with comma ‘,’.
Next, we will send an email of array values, so click on the Next step and select Send an Email (V2) action.
Now provide the To, subject, and in body part set the output of the Join from the dynamic content.
Now click on Save and run the Flow manually, you can see the result in the Outlook email.
Read Microsoft Flow Example: Copy files from one SharePoint Online account or folder to another
Power automate get array variable
Here we will see get unique values from the array of objects in Power Automate.
In Power Automate select the Manually triggered Flow. Then click on Next Step.
Select the Initialize variable action, then set the variable name, type as array, and in value set the array of objects like below:
From the array of objects, we need to get the unique values of last name. So for this we will first fetch all the last name in the objects.
So we will use the Select action, so click on the Next step and select Select action. Then in Form add the variable from the previous step and next in the Map field switch the map to text mode and write the below expression:
item()['LName']
Now to get the Unique last name, click on the Next step and select the Compose action. Then in input write the below expression:
Union(body('Select'),body('Select'))
Now click on Save and run the Flow manually. Now we can get the unique value from an array of objects.
This is how to get array variable using power automate.
Power automate get item from array variable
Here we will see how to get item from array of variables in Microsoft Flow.
We will create a flow from which we will get items from the array of objects in Microsoft Flow
In Power Automate click on Manually triggered Flow, Then click on Next step.
Select the Initialize variable action, and then set the variable name, type as array, and set the value like the below screenshot.
Now we will get an item that is in the 2nd index of array of objects. So, click on the Next step and select Compose action. Then in input write the below expression.
variables('varArray')?[1]
Now click on Save and run the flow manually. We can see the result in the compose output.
This is how to get items from an array variable using power automate.
Power automate get first item in array variable
Here we will see how to get first item in array variable in the Microsoft Flow.
We will create a flow that will extract the first item from the array in Microsoft Flow.
In Power automate, click on Manually triggered Flow. Click on the Next step.
Select Initialize variable action and then set the variable name, type as array, and set the value like below array of objects.
Now we will get the first item of the object, as we know array index starts with 0, so we will use the index value to get the first item.
So, click on the Next step and select the compose action. In input write the below expression:
variables('varArray')?[0]
Now click on Save and run the Flow manually. We can get the first item from the array of objects.
This is how to get first item in array variable in Power Automate.
Power automate length of array variable
Here we will see how to calculate length of array in Microsoft Flow.
In Power Automate, click on Manually triggered Flow. Then click on the Next step.
Select the Initialize variable action, and set the variable name, type as an array, and set the value like below.
Now we will calculate the length of an array by using the length function, so click on the Next step and then select the compose action. In input write the below expression:
length(variables('varArray'))
Now click on Save and run the flow manually, and you can see the length of the array is 4.
This is how to get the length of the array variable in Power Automate.
You may like the following Power Automate tutorials:
- Power Automate send email based on form response
- Power automate split string into an array with examples
- Power Automate Rename File
- Power Automate String Functions + 10 Examples
- Power Automate send email from shared mailbox
- Power Automate or Microsoft Flow check day of week
- How to move emails to folder after 30 days using Power Automate
- How to update SharePoint Multiselect column in Power Automate
In this Power Automate tutorial, we discuss different types of examples by using array variables in Power Automate. The examples are listed below:
- Power automate array variable apply to each
- Power automate array variable to string
- Power automate array variable index
- Power automate create array variable
- Power automate variable array of objects
- Power automate append array variable
- Power automate add array variable
- Power automate append to array variable json
- Power automate filter array variable
- Power automate remove duplicates from array variable
- Power automate email array variable
- Power automate get array variable
- Power automate get item from array variable
- Power automate get first item in array variable
- Power automate length of array variable
Bhawana Rathore is a Microsoft MVP (3 times in Office Apps & Services) and a passionate SharePoint Consultant, having around 10 years of IT experience in the industry, as well as in .Net technologies. She likes to share her technical expertise in EnjoySharePoint.com and SPGuides.com
It is awesome with insightful information!
I enjoy much reading the topics.
Thank you.
Can someone help me with array select issue? https://powerusers.microsoft.com/t5/Building-Power-Apps/Select-from-JSON-child-array/m-p/1486291#M384943