How to Create an Array From SharePoint List Items Using Power Automate?

I was working on a Power Automate project where I needed to create an array from SharePoint list items. The goal was to extract specific data from the SharePoint list.

In this tutorial, we will learn how to create an array from SharePoint list Items using Power Automate.

Create an Array From SharePoint List Items Using Power Automate

Imagine you have a SharePoint list named “Employee Directory” with the following columns:

  • Employee Name (Person or Group)
  • Department (Choice)
  • Status (Choice: Active/Inactive)
power automate create array from sharepoint list

I want to create an array of all active employee names from this list and use it in your Power Automate flow.

Now follow the below steps:

1. In the Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

Create an Array from SharePoint list Items using Power Automate

2. Add an Initialize variable action, provide a name, and select type as array:

power automate apply to each array variable

3. Next, add the Get items action to retrieve all the sharepoint list items and provide the below parameters:

  • Site Address: Select your SharePoint site address from the drop-down.
  • List Name: Select the SharePoint list from the drop-down.
power automate add value to array

4. Then add Append to array variable action and provide the below parameter:

  • Name: select the above array variable name.
  • Value: provide the below values:
{
"Employee Name": "@{items('For_each')?['EmployeeName/DisplayName']}",
"Employee Email":"@{item()?['EmployeeName/Email']}",
"Job Title":"@{item()?['EmployeeName/JobTitle']}",
"Department": "@{item()?['Department/Value']}",
"Status": "@{item()?['Status/Value']}"
}

Then, it will automatically add a For each loop.

Create Array from SharePoint list item using Microsoft flow

5. Outside of the for each action, add a compose action and provide the above array variable in the Input parameters.

Create an Array from SharePoint list Items in Power Automate

Now, click on save and run the flow manually. After the flow runs successfully, click the compose action to see the Output section. It displays the SharePoint list item values in an array format.

How to Create an Array from SharePoint list Items using Power Automate

Create an Array from a SharePoint list of Items Based on Condition using Power Automate

In the example above, we see all the items in the array. However, if you prefer, you can filter the items based on a condition. Now, let’s see how to create an array from a SharePoint list where the status is “Inactive.”

Now follow the below steps:

Create an Instant Cloud flow with the “Manually trigger a flow” option. Then, add an “Initialize variable” action, provide a name for the variable, and set the type to “Array.”

Example to create an array from get items using Power Automate

Add the “Get items” action to retrieve all the SharePoint list items. Then, provide the Site Address and List Name. Expand the “Advanced options,” select the “Filter Query,” and enter the following filter condition.

Status eq 'Inactive'
Example to create an array from get items using Power Automate flow

Next, add Append to array variable action, provide the above array name, and provide the below value using dynamic content:

{
  "Employee Name": "@{items('For_each')?['EmployeeName/DisplayName']}",
  "Employee Email": "@{item()?['EmployeeName/Email']}",
  "Job Title": "@{item()?['EmployeeName/JobTitle']}",
  "Department": "@{item()?['Department/Value']}",
  "Status": "@{item()?['Status/Value']}"
}

Then, it will automatically add a For each loop.

Create an Array from a SharePoint list of Items Based on Condition using Power Automate

Outside of the for each action, add a compose action and provide the above array variable in the Input parameters.

Power Automate Create an Array from a SharePoint list of Items Based on Condition

Now, click on save and run the flow manually. After the flow runs successfully, click the compose action to see the Output section. You can see only the inactive status.

Create an Array from a SharePoint list of Items Based on Condition in Power Automate

Conclusion

In this tutorial, we learned how to create an array from SharePoint list items using Power Automate. I showed you how to retrieve data from a SharePoint list, initialize an array variable, and append specific data (like employee names, emails, job titles, departments, and statuses) to the array.

Additionally, we explored how to filter the list items based on a condition, such as retrieving only employees with an “Inactive” status.

Some more articles you may also like:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…