Skip to main content

How to Filter an Array by Two Conditions in Power Automate

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Filter array takes one condition in its basic mode. For two, switch it to advanced mode and write one expression that joins them with and(): an item is kept only when both are true. Here: the entry's department is in a list, and the person running the flow didn't write it.

The basics of Filter array, with one condition, are in How to Filter an Array in Power Automate. This guide adds the second condition.

The example is Get Waiting Approvals, a flow of the Overtime Timesheet app. Of the pending overtime entries, it keeps those in the departments the caller approves, except the caller's own: their own overtime goes to someone else.

Prerequisites​

Step 1: Add Filter Array and Choose the Array​

Add Filter array under Data Operation. I named it Entries waiting for the caller. In From, pick the array: body/value of Get the pending entries.

Step 2: Switch to Advanced Mode​

Under the condition row, select Edit in advanced mode. The row becomes one box for an expression that starts with @.

Step 3: Write Both Conditions in and()​

Type or paste the expression into the box, as one line. Typing / in that box opens the token menu, so the expression starts with @, not /:

Entries waiting for the caller → Filter Query (advanced mode)
@and(contains(variables('MyDepartmentIds'), int(string(item()?['DepartmentId']))), not(equals(toLower(item()?['Author']?['Email']), toLower(outputs('Get_the_caller')?['body/mail']))))

Each part:

  • item() is the entry being checked.
  • First condition: contains() is true when the list of department IDs includes the entry's DepartmentId. int(string(...)) turns the SharePoint number into a whole number first. Without it, contains() never matched (Fixed: contains() Returns False for a SharePoint Number in Power Automate).
  • Second condition: equals() compares the email of the entry's author, Created By (Author), with the caller's. not() turns it around, so the caller's own entries are left out. Both emails go through toLower().
  • and() is true only when both are.

Code view shows the action:

The Code view of Entries waiting for the caller: type Query, from the outputs of Get_the_pending_entries body/value, and where set to the and expression with contains of MyDepartmentIds and int(string(item()?['DepartmentId'])), and not equals of the author's and the caller's lower-case emails

The Result​

Two Radiology entries were pending: one of mine, one of Daniel's. For Daniel, the approver of Radiology, the action kept only mine, and the app showed it:

The Waiting for approval screen saying 1 entry is waiting for your decision, with one card: Admin User, Mon 09/11/2026, 17:00 to 19:00, 2.00 hours, Radiology, Waiting since 10/11/2026 11:20

Common Mistakes​

MistakeWhat happensDo this instead
Two Filter array actions, one per conditionIt works, with an extra actionOne and() in advanced mode
or() instead of and()Items matching only one condition are keptand() when both must be true
Comparing emails without toLower()A capital letter stops a matchtoLower() on both
contains() on a SharePoint numberIt doesn't matchint(string(...))

Troubleshooting​

SymptomLikely causeFix
The output is always []One condition is always falseShow each part with a temporary Select (the contains() fix shows how)
The expression won't saveA missing bracketCount the brackets; Code view shows the saved text
A token menu opens while typing/ typed into the boxType or paste the expression without starting with /

FAQ​

Can I go back to basic mode?​

Not with this expression: with and() in it, Edit in basic mode was greyed out, so the condition stays in advanced mode.

What about three conditions?​

and() takes more than two: and(a, b, c) is true when all three are. Microsoft's functions reference says it checks whether all expressions are true.

Conclusion​

For two conditions in Filter array, use Edit in advanced mode and join them with and(). Here, contains() kept the approver's departments and not(equals()) left out their own entries, in one action.

Additional Resources​