Power Platform 7 min read

Mastering the Filter Array Action in Power Automate: From Basics to Multi-Column Queries

Quiz available

Take a quick quiz for this article.

Mastering the Filter Array Action in Power Automate: From Basics to Multi-Column Queries
A comprehensive technical guide to mastering the Filter Array action in Power Automate, from basic single-column queries to advanced, multi-column condition filtering with custom expressions.

Mastering the Filter Array Action in Power Automate: From Basics to Multi-Column Queries

When building flows in Power Automate, the Filter Array action is easily one of the most underrated tools at your disposal. While it appears simple on the surface, mastering it allows you to process complex JSON arrays and extract exactly the data you need without resorting to clunky loops or apply-to-each iterations.

In this technical guide, we will start with the basics of filtering single columns, dive into handling nested JSON objects, and finally, unlock the true power of this action by using advanced expressions to filter across multiple columns simultaneously. We will also cover essential workarounds for navigating the current quirks of the Power Automate designer.


Prerequisites

To follow along with these examples, create an Instant Cloud Flow (manually triggered). Use the Initialize variable action to define your arrays before passing them into the Filter Array action.


Level 1: The Basics (Filtering a Flat Array)

Let’s start with a simple, flat JSON array containing user records. Each record has a firstName and an age.

Code
[
  { "firstName": "John", "age": 19 },
  { "firstName": "Ali Raza", "age": 23 },
  { "firstName": "Puya", "age": 34 }
]

The Goal: Return an array containing only the people older than 20.

  1. Add the Filter array action to your flow.
  2. In the From field, pass in your array variable.
  3. In the first condition box, you need to reference the current item being evaluated. You cannot select this from the dynamic content menu; you must write an expression.
  4. Open the expression builder and type: item()?['age'] (or item().age). The item() function represents the current row in the loop.
  5. Set the operator to is greater than.
  6. Set the value to 20.
⚠️

Developer Note: The Power Automate designer often fails to look inside your array to suggest column names (Intellisense Limitations). Do not rely on auto-suggest here; type the property exactly as it appears in your JSON.


Level 2: Intermediate (Filtering Nested JSON Objects)

Data is rarely perfectly flat. Often, you will deal with nested JSON properties. Let’s upgrade our array so that name is its own object containing firstName and lastName.

Code
[
  { "name": { "firstName": "Sarah", "lastName": "Jones" }, "age": 28 },
  { "name": { "firstName": "David", "lastName": "Jones" }, "age": 45 },
  { "name": { "firstName": "Mark", "lastName": "Smith" }, "age": 32 }
]

The Goal: Filter the array to return only users with the last name “Jones”.

Code
flowchart TD
    A[Row Context `item()`] --> B("Traverse Properties:\n `?['name']?['lastName']`")
    B --> C{Equals 'Jones'?}
    C -- Yes --> D([Keep Record])
    C -- No --> E([Discard Record])

The process is identical to Level 1, but we must traverse the JSON hierarchy in our expression.

  1. Add the Filter array action.
  2. In the expression builder for the first column, string your properties together: item()?['name']?['lastName'] (or item().name.lastName).
  3. Set the operator to is equal to.
  4. Set the value to Jones.

When executed, the output body will perfectly strip away “Mark Smith” and return only the two “Jones” records.


Level 3: Advanced (Multi-Column Filtering)

By default, the Filter Array UI only allows you to evaluate one condition. It does not have an “Add row” button to stack logic like other actions in Power Automate. To filter by multiple columns, we have to bypass the standard UI and write custom code in Advanced Mode.

Let’s say we want to filter our nested array for a very specific record: The person’s first name must be “Ali Raza” AND their age must be greater than 20.

Code
flowchart LR
    Start([Input: Nested Array]) --> Check{"firstName == 'Ali Raza'\nAND\nage > 20"}
    Check -- True --> Keep([Include in Output Array])
    Check -- False --> Drop([Discard Row])

To achieve this, we need to combine three Power Automate functions:

Core Expression Functions
FunctionSyntaxPurpose
Equals equals(parameter1, parameter2) Evaluates exact string matches.
Greater greater(parameter1, parameter2) Evaluates numerical thresholds.
And and(cond1, cond2) Combines multiple logic conditions.

Building the Expression Step-by-Step

Step 1: Write the Name Condition Remember that in Power Automate formulas, you cannot use standard mathematical operators like an = sign. You must use the explicit function.

Code
equals(item()?['name']?['firstName'], 'Ali Raza')

Step 2: Write the Age Condition Similarly, you cannot use the > symbol.

Code
greater(item()?['age'], 20)

Step 3: Combine with AND Wrap both formulas inside the and() function, separated by a comma.

Code
@and(
  equals(item()?['name']?['firstName'], 'Ali Raza'),
  greater(item()?['age'], 20)
)

Step 4: Apply the Advanced Formula In your Filter Array action, delete whatever is currently in the boxes. Click the button to switch to Advanced mode and paste your complete @and(...) expression directly into the text box.


🛑 Crucial Developer Tips and Workarounds

Working with complex expressions in Power Automate can sometimes be frustrating due to UI quirks. Keep these best practices in mind to save yourself hours of troubleshooting:

Never write complex logic directly in the browser. Always keep a backup in your code editor.

— Power Automate Best Practices | Developer Warning
Designer Modes Comparison
Designer TypeStability (Advanced Mode)Best For
Modern Designer
⚠️ Glitchy
Simple, standard UI filtering
Classic Designer
Stable
Writing and saving complex expressions
🔙

The Classic Fallback: If the modern designer refuses to accept your formula, glitches out, or drops constraints, save your flow and switch to the Classic Designer. Input your formula there—it is often much more reliable for advanced expressions.

💻

Off-Browser Editing: Because the UI can sometimes scramble or delete your formulas when you click away, always write your complex expressions in Notepad or VS Code first. Keep a copy of the formula safely saved on your machine before you paste it into Power Automate and hit update. Ensure you have a backup if you need to roll back.


By mastering these three levels of the Filter Array action, you can dramatically improve the performance and readability of your flows. Filtering arrays in-memory is vastly superior to iterating through rows via “Apply to each”, saving both execution time and action API calls.

Related Articles

More articles coming soon...

Discussion

Loading...