Skip to main content

Filter and branch data in workflows

Learn how to perform conditional logic using Filter and Branch blocks in Retool Workflows.

Filter and Branch blocks enable you to write logic to perform actions with a specific subset of data, or perform different actions depending on multiple conditions.

Filter data

If an item evaluates as true, the Filter block includes it in the data it returns.


Optimize your queries to filter data and return only the results you need first (e.g., use LIMIT or WHERE clauses).

Filter blocks function similar to Loop blocks and iterate through the query you select from the Iterable dropdown. Set the Filter Expression to a condition that evaluates as true, using value and index to reference evaluated items and their indexes.

For example, you can use a Filter block to return a list of customers who are outside the United States with != 'USA.

Branch data and perform different actions

Instead of writing if...else statements in JavaScript, you can use Branch blocks to visually build conditional statements that control different connected blocks. This is useful for breaking out complex JavaScript logic into more manageable blocks.

A Branch block evaluates the data it receives from a connected block using the defined condition. If the condition evaluates as a truthy value, the workflow follows the control flow for the If statement. If not, it follows the control flow for the Else statement.

For example, you could build a workflow that alerts your shipping department if the number of international customers exceeds a certain threshold, such as > 90.

You can add multiple branches as Else if statements and visually build out complex conditional logic. As you test your workflow, the condition that evaluates as true is highlighted in green.

Each conditional statement has its own connector so you can connect different blocks and define separate control flows for each outcome.