Yes, you can add filter arrays in Power Automate to quickly narrow down data without editing every step manually. It saves hours—especially when dealing with large lists, repeated actions, or conditional logic. First, ensure you’re using the Microsoft Graph Connector or a supported data source (like Excel, SharePoint, or Dataverse) that supports array filtering. For custom arrays, use the "Filter array" action with a custom script if no built-in option exists.
What You'll Need
- Power Automate desktop or web app (version 3.0+ recommended, as older versions lack some array features)
- An action that returns data as a list or array (e.g., "Get items from SharePoint," "Get rows from Excel," or "Get items from Dataverse")
- Basic knowledge of JSON syntax for array formatting (see "Tips" for a cheat sheet)
- A supported data source that accepts array-based filtering (see "Common Mistakes" for unsupported sources)
Step-by-Step
- Start a new flow: - On the web app: Click "Create" > "Automated cloud flow." - On desktop: Open Power Automate, click "New flow" > "Automated."
- Add a "Get items" action:
- For SharePoint/Teams: Select "Get items" from the "Microsoft Dataverse" or "SharePoint" category.
- For Excel Online: Use "Get range" or "Get rows from Excel Online."
- For custom data (e.g., REST API): Choose "HTTP request" and set the method to GET.
- In the "Items" field, enter a query like:
{ "Category": "Apparel", "Price": "gt", 40 }(Replace with your actual column names and filters.) - Add a "Filter array" action:
- This is the core step. Insert a "Filter array" action from the "Actions" tab.
- For array-based filtering:
- In the "Array" field, paste the output from your first action (e.g., the entire list of items).
- In the "Filter" field, use a JSON-like syntax to define conditions. Example:
{ "Status": "Active", "CreatedDate": "gte", "2023-01-01" }(For multiple fields, combine with logical operators like AND/OR.) - For dynamic arrays (e.g., user inputs): - Use a "Set variable" action first to store the filter logic (e.g., `@variables('FilterPattern')`). - In the "Filter" field, reference the variable directly, like:{ "columns": "@variables('FilterPattern')" } - Test the filter: - Run the flow in preview mode. Check the output for the filtered results. - If the array is malformed, Power Automate will show an error—review your JSON syntax (see "Common Mistakes" for fixes).
- Add subsequent actions: - Chain the filtered output into actions like "Create item," "Send email," or "Update record." - For complex logic, use "Apply to each" after filtering to loop through the array.
- Save and test: - Click "Save" and run the flow to verify the filter works as expected. - If using a trial account, enable "Simulate" mode to test without real data.
Common Mistakes
- Unsupported data sources: Not all connectors support array filtering. SharePoint, Excel Online, Dataverse, and Microsoft Graph (via "Get items") work best. Custom APIs or legacy connectors (pre-2023) may fail. Fix: Use a supported source or switch to a "Filter" action (for single fields) instead of "Filter array."
- Incorrect JSON syntax : Power Automate treats array filters as JSON. Common errors: - Missing braces: `{"Status": Active}` → `{"Status": "Active"}` Fix: Open a text editor (not the Power Automate interface) to validate your JSON.
- Empty arrays after filtering: The "Filter array" action returns an empty array if no items match. Add a "Set variable" or "Choose" action to handle this case.
Fix: Use a conditional:
{ "if": { "result": { "items": "@items()", "length": "@items().length", "value": "@items().length > 0" } } } - Field name mismatches: Ensure column names in your query match the actual data schema. Fix: Use "View data" in the "Get items" action to preview the output before filtering.
Tips
- Cheat sheet for array syntax: Use this template for complex filters:
{ "Field1": "value", "Field2": "gte", 100, "AND", {"Field3": "contains", "String" } }(Replace placeholders with your actual fields.) - Reuse filters: Store filter logic in a variable to avoid retyping. Example:
"FilterPattern": "{ "Status": "Active", "Date": "gte", "2023-01-01" }"Then reference it in the "Filter" field:"@variables('FilterPattern')" - Performance: For large arrays, filter early in the flow to reduce processing time.
- Debugging: Enable "Include details" in the "Get items" action to see raw responses. Use the "Inspect" tool in Power Automate (click the play icon next to an action) to debug JSON syntax.
Troubleshooting
- Flow fails with "JSON decode failed":
- Check the error message for malformed syntax.
- Open the error in a text editor to count braces/punctuation.
- If using a custom script: Ensure the filter logic is valid JSON. Example of a working script:
"@json(renderJson('[ { "Status": "Active", "Price": "gt", 50 } ]'))" - Filter returns no results: - Verify your query matches the actual data (e.g., case-sensitive strings, exact dates). - Test the filter separately in a "Set variable" action to isolate the issue.
- Desktop app vs. web app: - On desktop, array filtering is identical to the web app. The "Filter array" action is the same in both. - If using a desktop-only connector (e.g., "Get files from OneDrive"), ensure it supports filtering (not all do).
- Need to filter before the first action:
- Use the "Get items" action with a dynamic query (e.g., `@variables('FilterPattern')`).
- Example:
@json(renderJson({ "Category": "Electronics" }))
Frequently Asked Questions
How do I filter an array in Power Automate if the source is not SharePoint/Excel?
You can’t use the built-in "Filter array" action for unsupported sources like REST APIs or legacy connectors. Instead: 1. Add an "HTTP request" action to fetch data. 2. Use a "Parse JSON" action to decode the response. 3. Apply filtering in a custom script (see "Common Mistakes" for syntax).Can I filter by multiple fields at once with "Filter array"?
Yes, but combine conditions with logical operators. Example:{ "Age": "gt", 25, "AND", {"Department": "Sales" } }
(Replace with your actual fields.)
What if my filtered array is empty?
Add a "Set variable" action to handle empty results:"FilteredResults": { "items": "@items()", "length": "@items().length" }
Then use a "Choose" action to branch based on `@filteredResults.length == 0`.
How do I filter dynamic values (e.g., user input)?
Store the filter logic in a variable first:"UserFilter": "Status=Active"
Then reference it in the "Filter" field:
"@variables('UserFilter')"
Use a "Parse JSON" action if needed.
Is there a "Filter array" action for Office 365 lists?
Yes, but only in the "Get items" action. Example:{ "Title": "contains", "Task" }
For advanced queries, use "Filter array" after fetching data.