Overview
This lesson is part of the n8n AI Automation - Zero to Hero course, Section: 3. Deep Dive Concepts.
Watch the video above for the full tutorial, or read the written guide below.
What is conditional logic in n8n, and when do you use the IF node versus the Filter node?
The IF node routes every incoming item into one of two branches, a true path or a false path, based on one or more conditions you define. The Filter node evaluates the same kind of conditions but silently discards items that fail and outputs only one branch. Use the IF node when you need to act on both outcomes. Use the Filter node when the false case requires no action and you want a cleaner canvas.
How to build branching workflows, control execution order, and merge results in n8n
n8n supports three branching types. Conditional branching uses the IF node to split a workflow into a true path and a false path, for example flagging a qualified lead versus an unqualified one. Multipath branching uses the Switch node to create any number of output branches, one per matching condition, such as routing orders by status into pending, processing, cancelled, and refunded paths. Parallel branching fires multiple downstream nodes from a single source node at the same time, like sending both an email and a Slack message for every cancelled order from the same branch output.
Execution order in n8n follows two deterministic rules: top-to-bottom first, then left-to-right when nodes sit at the same height on the canvas. One branch runs to completion before the next starts. This sequence matters because if a node in Branch C depends on data produced by Branch A, but Branch C sits higher or further left, n8n executes it first and the workflow breaks or returns empty results. Arranging branches deliberately on the canvas to match the dependency order you need is not optional; it is structural correctness.
The Merge node resolves multi-branch workflows by waiting for all connected branches to finish, then combining their outputs into a single dataset. In the lesson demo, two parallel Google Sheets queries fetch order headers (104 rows) and order details separately. The Merge node joins them on the shared Order ID field and produces 291 unified rows. Every downstream node from that point works on one clean dataset instead of two disconnected streams.
Key Takeaways
- The IF node creates two executable branches (true and false); the Filter node outputs only matched items with no false branch, making it the right choice when failed conditions need no handling.
- n8n's three branching types are conditional (IF node, 2 paths), multipath (Switch node, n paths matched by field value), and parallel (multiple nodes connected to one output firing at the same time).
- Execution order is top-to-bottom then left-to-right, and each branch completes fully before the next starts, so placing a dependent node in the wrong position breaks data availability for that node.
- The Merge node waits for all incoming branches, combines results on a matching field such as Order ID, and returns one unified dataset so downstream processing stays coherent.
- Optimizing a multi-branch workflow sometimes means merging branches before a shared action rather than duplicating that action per branch, as shown when cancelled and refunded orders both feed one Merge node before a shared email and Slack step.
Related Lessons
- Lesson 11: How Branching works in n8n Workflows | Smart Automations with Multiple Paths
- Lesson 12: How to Use Merge Node in n8n | Combine Data Like a Pro
- Lesson 13: How to Use Set Node in n8n | Edit Fields Node | Add, Edit, Clean Data
- Lesson 14: How to Use Aggregate Node in n8n | Combine & Summarize Data
- Lesson 15: How to Use Remove Duplicates Node in n8n | Clean Your Data Fast
Next Steps
Continue your n8n journey with the full n8n AI Automation - Zero to Hero course.