How to use the Filter Array Step
Last updated
Was this helpful?
Last updated
Was this helpful?
Using the Filter Array Step
This support article provides a detailed explanation of how to use the "Filter Array" step in Flows, a powerful workflow automation tool.
The "Filter Array" step allows you to selectively extract elements from an array based on specific conditions. This step is crucial for processing data within your workflows, ensuring that only the relevant information is passed to subsequent steps.
Use Filter array when you:
Want to extract specific values from an array.
Need to apply conditional logic to an array of objects.
Want to reduce data before sending it to another step (e.g., email, webhook, loop).
The "Filter Array" step requires an input array and a condition. The condition is evaluated for each element of the input array. If the condition is met, the element is included in the output array.
Here is an example of how the "Filter Array" step can be used:
Example: Filtering Policies
Consider the following JSON data representing a list of policies:
Let's say you want to filter only the "owner" policies. You can use the "Filter Array" step with the following condition:
Property to filter on: Type the property key within curly braces, {{type}} , in this case. In case you want to filter on the name or policy number it would be {{name}} or {{policy_no}} respectively.
Comparison: Choose the comparison operator in this case it’s Is Equal to.
Value: type the value of the property you want to filter. Remember this is case sensitive so make sure you are typing the exact value you want to filter on. In this case, it’s owner
This will result in an output array containing only the "owner" policy.
Policy Name
Policy Number
Policy Type
Some policy
123918309821
owner
Array to filter: Select the list_policies array from the step output of the set variables step, in this case. You can do so by selecting the variable picker and navigating through the step output of your choice and hitting the select option on the array.