Filter Array in Power Automate Examples

I was recently working on the Filter Array in Power Automate, where we can filter the items in the array by using different types of operators in the Filter Array action.

This tutorial explains how to use filter query operators in the Filter Array action of Power Automate. Here we will see the following examples:

  • How to use Filter Array Equals in Power Automate
  • Filter Array Not Equals Operator in Power Automate
  • Power Automate Filter Array greater than
  • Filter Array Less Than using Power Automate
  • Filter the Array based on AND
  • Use AND OR Expression in Filter Array using Power Automate

Example 1: Power Automate Filter Array Equals

Let’s consider that you have an Array in Power Automate containing details about construction materials with multiple items, as shown in the code below. Here, I want to filter the items where the ‘LowStock’ value is equal to ‘true’.

[
  {
    "Material": "Cement",
    "Quantity": 500,
    "Unit": "Bags",
    "LowStock": false
  },
  {
    "Material": "Bricks",
    "Quantity": 10000,
    "Unit": "Pieces",
    "LowStock": false
  },
  {
    "Material": "Steel",
    "Quantity": 200,
    "Unit": "Tons",
    "LowStock": true
  }
]

You can do this by using the steps below in Power Automate. I will create a button flow in Power Automate

  1. Create a button flow in Power Automate that can be triggered by a single click of a button.
  2. To store the array value, add an “Initialize variable” flow action and set the parameters, such as NameType [Set to Array], and Value.
Power Automate Filter array equals
  1. To filter the array items, add the “Filter Array” action and set the required parameters.
    • From: Select the ‘Initialize variable’ from the dynamic content.
    • Filter Query: Add the filter query mentioned below in the table.
Choose ValueOperatorChoose Value
Click on Insert Expression -> item()?[‘LowStock’]is equal totrue
Filter array equals in Power Automate

Now save and run the flow. To do that, click on the Save icon and then the Test button.

Output:

Filter array equals Power Automate

Check out Replace String in JSON using Power Automate

Example 2: Power Automate Filter Array Not Equals

Let’s see how not equals works in the filter array action. Here, I will use the same Array as mentioned in the above example.

In the provided array, the filter array should return the remaining two array items where the ‘LowStock’ value is not equal to ‘true.

In the filter query, let’s change the operator to ‘is not equal to’.

Choose ValueOperatorChoose Value
item()?[‘LowStock’]is not equal totrue
Power Automate Filter array not equal

Output:

Filter array not equals Power Automate

Example 3: Power Automate Filter Array Greater Than

You often need to filter the items in a SharePoint list based on specific criteria according to our requirements.

In this example, I will explain how to filter a list array using the greater than operator in the Filter Array action.

Below, you can see a SharePoint list named ‘Employee Travel Voucher List‘ with different types of data. From that, I wanted to filter out the items that have a ‘Voucher Amount’ value greater than ‘2000’.

Power Automate Filter array greater than

To do this, I will create a Power Automate Instant cloud flow. Click here to learn how to make different types of flows in Power Automate.

You can start from the steps mentioned below:

  1. Under the trigger [Manually trigger a flow], add a “Get Items” action to fetch all the SharePoint list items. Provide Site Address and List Name.
Filter array greater than Power Automate
  1. Then, add a ‘Filter Array’ action to filter out the list of array items, which will filter the items with a “Voucher Amount” value greater than 2000. Set the required parameters.
    • Name: Take the body/value of the Get items action from the dynamic content.
    • Filter Query: Insert the values provided in the table below.
Choose ValueOperatorChoose Value
@{item()?[‘VoucherAmount’]}is greater than2000
Filter array greater than in Power Automate
  1. Next, add the ‘Create HTML table‘ action to create a table containing the filtered items. Provide the parameters, such as ‘From’‘Columns with Custom Headers’, and ‘Values’.
HeadersValues
Employee Name@{item()?[‘Title’]}
Voucher Amount@{item()?[‘VoucherAmount’]}
Expiry Date@{item()?[‘Expiry_x0020_Date’]}
Usage Status@{item()?[‘UsageStatus/Value’]}
Power Automate Filter array greater than operator
  1. Now, I will take the “Send an email(V2)” action to view the output of the create HTML table action. Provide parameters such as ‘To’, ‘Subject’, and ‘Body’ with the Output of the Create HTML table. Have a look at the image below.
How to use Power Automate Filter array greater than

Now the flow is ready. Save and test the flow manually.

Output:

Power Automate Filter Query greater than Filter Array

Example 4: Power Automate Filter Array Less Than

To illustrate this example, I will use the same SharePoint list as in the previous example, [Example 3].

Here, follow the similar steps, but update the Filter Query in the Filter Array action. I will change the operator to is less than. It should filter out the items that have a ‘Voucher Amount’ value less than ‘2000’.

  1. In the ‘Filter Array‘ action, set the filter query as mentioned in the table below.
Choose ValueOperatorChoose Value
@{item()?[‘VoucherAmount’]}is less than2000
Filter array less than in Power Automate

Output:

Power Automate Filter array less than

Example 5: Power Automate Filter Array And

Let’s consider an array of ‘Sales Records’, where I want to filter the array items based on ‘Region of South‘ and ‘Amount less than 5000‘.

[
  {
    "SalesID": "S001",
    "SalesPerson": "Arjun",
    "Region": "North",
    "Amount": 15000
  },
  {
    "SalesID": "S002",
    "SalesPerson": "Meena",
    "Region": "South",
    "Amount": 2000
  },
  {
    "SalesID": "S003",
    "SalesPerson": "Rahul",
    "Region": "East",
    "Amount": 12000
  },
  {
    "SalesID": "S004",
    "SalesPerson": "Divya",
    "Region": "South",
    "Amount": 4500
  }
]

Follow the steps below:

  1. Create a Power Automate Instant cloud flow.
  2. Then, add an ‘Initialize variable‘ action to set the array values to it. See the screenshot below.
Power Automate filter array and
  1. After that, add a ‘Filter Array’ action to filter array items based on the required condition.
    • Name: Take an Initialize variable[VarSalesRecords]from dynamic content.
    • Filter Query: Click on Edit in advanced mode option ->Set the following expression in the filter query.
and(equals(item()?['Region'],'South'),less(item()?['Amount'],5000))
Filter array and in Power Automate

Save and run the flow..

Output:

Filter array and Power Automate

To filter the Array items with the (OR) operator, you can follow this expression:

or(equals(item()?[‘Region’],’South’),equals(item()?[‘Amount’],5000))

Example 6: Power Automate Filter Array based on [AND, OR]

Let me use one of my SharePoint lists to explain this example.

Here, I will take a SharePoint list named ‘Budget List’ with different types of columns. I wanted to filter the items based on the condition like:

  • Category as HR and Allocated Amount Less than 5000,(OR)
  • Category – Any type and Allocated Amount equals 5000
Power Automate filter array expression and or

You can follow the same steps as mentioned in the example [Example 3]. But only change the Filter Query in the Filter Array action.

  1. Add a ‘Filter Array’ action and set the below-mentioned parameters.
    • Name: Take Body/Value of the get items action from the dynamic content.
    • Filter Query: Click on Edit in advanced mode -> Insert the expression below.
or(and(equals(item()?['Category/Value'], 'HR'), equals(item()?['AllocatedAmount'], 5000)), less(item()?['AllocatedAmount'], 5000))
Filter array and or in Power Automate

Now, save and run the flow.

Output:

Power automate filter array and or expression

This is all about Filter query operators that can be used in the Filter Array action of Power Automate.

I hope you found this article helpful. Do mention your suggestions or comments in the comments section.

You may like the following 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…