How to Filter an Array by Another Array in Power Automate?

Today, I will discuss an interesting example, and it is about filtering an array by another array in Power Automate. In this tutorial, I will show you how to filter an array with another array using the Power Automate Filter array action.

You can learn two different examples here, such as:

  • Filtering an array with another array in Power Automate [Manually Created Arrays]
  • Filtering two Excel arrays using Power Automate

Filter an Array with Another Array in Power Automate

For this example, let me create two array variables manually, where each variable stores an array of objects.

You can see the two arrays below in the code:

Course Details Array:

[
  {
    "CourseName": "Power Automate Essentials",
    "CourseID": "CRS001",
    "Technology": "Power Platform",
    "Tutor": "Joseph David",
    "StartDate": "2025-07-01"
  },
  {
    "CourseName": "Introduction to SharePoint",
    "CourseID": "CRS002",
    "Technology": "SharePoint",
    "Tutor": "Alex Wilber",
    "StartDate": "2025-07-05"
  },
  {
    "CourseName": "Azure Fundamentals",
    "CourseID": "CRS003",
    "Technology": "Azure",
    "Tutor": "Jo Anne",
    "StartDate": "2025-07-10"
  },
  {
    "CourseName": "Power BI for Beginners",
    "CourseID": "CRS004",
    "Technology": "Power BI",
    "Tutor": "John Mathews",
    "StartDate": "2025-07-08"
  }
]

Enrolled Courses:

[
  {
    "StudentName": "Meera Patel",
    "CourseID": "CRS003",
    "Technology": "Azure"
  },
  {
    "StudentName": "Nisha Rao",
    "CourseID": "CRS002",
    "Technology": "SharePoint"
  }
]

From these two arrays, I wanted to filter out students who were not enrolled in specific courses based on the Course ID. Therefore, the filter array should display the array values, excluding the course items that are not enrolled in.

We can achieve this by using the Filter Array action in Power Automate.

Here are the steps to do this:

  1. Let me create an Instant cloud flow in Power Automate.
  2. Then, add an ‘Initialize variable‘ action to set the array values in a variable. Provide a variable name, choose type as (Array), and value with an array of objects mentioned above.
Power Automate Filter Array with another array
  1. Next, take a Compose action, which will store the other array values, i.e., the students who are enrolled in courses.
Filter Array with another array Power Automate
  1. Following that, add a ‘Select‘ action to set the array of Course IDs from the students array to check the Course ID matches in the Course Details Array. Set the parameters given below.
    • From: Choose the outputs of the Compose action.
    • Map: Click on Switch to text mode -> Enter the expression below.
@{item()?['CourseID']}
Filter an Array by Another Array in Power Automate

Now, I want to filter an array [Course Details] with another array [Enrolled Courses], where the filtered items should return the array values for which students are not enrolled.

  1. For this, add a ‘Filter array‘ action to filter the Course IDs in both arrays. Set the required parameters below.
    • From: Select the initialize variable output from the dynamic content.
    • Filter Query: The query is placed in the table below.
Choose ValueOperatorChoose Value
@{body(‘Select’)}does not contain@{item()?[‘CourseID’]}
Power Automate filter two arrays
  1. To display the filtered array values, I will add the ‘Compose’ action. In the ‘Inputs’ parameter, select Body of Filter array from the dynamic content.
Power Automate Filter Array by another array
  1. Now, the flow is completed. To save the flow, click on the Save icon. Then run it manually.

Output:

Filter Array by another array Power Automate

That’s how you can filter an array of objects by another array using Power Automate.

Check out How to Filter an Array by String Values in Power Automate?

Filter Two Excel Arrays using Power Automate Filter Array

Suppose you have two Excel files that contain ‘Course details’ and ‘Enrolled Students’ details, who enrolled in a particular Technology in your SharePoint document library.

Course Details:

Filtering arrays in Power Automate

Enrolled Students:

Filter Array using another array in Power Automate

In both the Excel sheets, I wanted to filter the Array of the Enrolled Student list, where Enrolled Technology matches the ‘Technology’ present in the Course Details Excel sheet. Based on the filtered items, update the ‘Course Status’ for the enrolled student.

Check out the steps mentioned below:

  1. I will create a Power Automate Instant cloud flow that updates all Excel rows with a single click of a button.
  2. To fetch the rows present in an Excel table of [Course Details], add the “List rows present in a table” action. Configure the parameters present in it.
    • Location: Select the file location, such as SharePoint, OneDrive, or Groups, etc.
    • Document Library: Choose the specific document library where the file is stored.
    • File: Select a specific Excel file present in the library.
    • Table: Add a table from the drop-down options.
Power Automate Compare Two Arrays
  1. Then, add one more “List rows present in a table” action that will fetch records from the Enrolled Students Excel file. Set the parameters, such as Location, Document Library, File, and Table.
Filter array by another array Microsoft Power Automate
  1. Next, add a ‘Select’ action to set the array, which will be used for comparison in the Filter Array action.
    • From: Take the body/value of the list rows present in the Excel table action [Enrolled Students].
    • Map: Switch to text mode -> add Enrolled Technology column from dynamic content.
Filtering Array with Array in Power Automate
  1. Now, take a Filter array action to filter one Excel array by another Excel array. Configure the parameters.
    • From: Add body/value from the dynamic content of [Course Details].
    • Filter Query: Provide the query given in the table below.
Choose ValueOperatorChoose Value
@{body(‘Select’)}is equal to@{item()?[‘Technology’]}
Filter an Array by another array in Power Automate
  1. After that, add the ‘Apply to each loop‘ action. Select an output from previous steps to: Filter Array Body [@{body(‘Filter_array’)}].
Power Automate Filter two arrays of objects
  1. Inside the loop, take the ‘Update a row‘ action that updates each row each time the flow runs. Set all the required parameters.
    • Location: Choose the Excel file location.
    • Document Library: Select the SharePoint document library where the file is present.
    • File: Select a File name from the drop-down.
    • Table: Add the Table from the drop-down options.
    • Key Column: To identify the row, we need to provide a Key Column that has a unique identifier for each row. In my case, it is Enrolled Technology.
    • Key Value: Add the dynamic content of ‘Technology’ here.
    • Course Status: Provide @{item()?[‘CourseStatus’]}.

Replace ‘CourseStatus’ with your Excel column name.

Microsoft Power Automate Filter Array with another array

The flow is ready now. Save and test it.

Output:

Power Automate Filter an Array by another array

This way, you can filter an array with another array using the Power Automate Filter array action.

You may also like the following Power Automate tutorials:

>

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…