Smart Data Filtering and Routing with If and Switch Nodes
detail.loadingPreview
This workflow demonstrates essential conditional logic using n8n's If and Switch nodes. Learn to filter and route incoming data based on single conditions, complex AND/OR criteria, or multiple branching paths. It's a foundational example for intelligent data processing.
About This Workflow
Unlock the power of dynamic data processing with this comprehensive n8n workflow. Designed to showcase the versatility of the If and Switch nodes, this example allows you to intelligently filter and route customer data. You'll see how to apply simple conditions, combine multiple criteria with AND or OR logic, and create intricate branching paths for different data segments. This workflow is a perfect hands-on guide for anyone looking to implement robust conditional automation and ensure data flows precisely where it needs to go, every time, enhancing the efficiency of your operational workflows.
Key Features
- Single Condition Filtering: Easily filter data based on a single criterion, such as
country equals US. - Advanced AND/OR Logic: Combine multiple conditions using
ANY(OR) orALL(AND) operators for sophisticated data matching, likecountry is empty OR name contains 'Max'. - Multi-Path Data Branching: Route data to multiple distinct paths with the
Switchnode, efficiently handling more than two outcomes based on specific values (e.g., country-based routing for US, CO, UK). - Customer Datastore Integration: Demonstrates fetching data from a hypothetical customer datastore for practical application, providing a realistic scenario.
How To Use
- Start the Workflow: Click
Execute Workflowto fetch sample customer data from theCustomer Datastorenode. - Configure Single Conditions (
Ifnode): Double-click the "Country equals US" node. In theConditionssection, specify your desiredvalue1(e.g.,={{$json["country"]}}) andvalue2(e.g.,US) to filter data based on a single criterion. - Implement AND/OR Logic (
Ifnode): For complex filtering, double-click the "Country is empty or Name contains 'Max'" node. Add multiple conditions underConditions, then set theCombinefield toANYforORlogic (orALLforANDlogic). - Set Up Multi-Branching (
Switchnode): Double-click the "Country based branching" node. Define thevalue1to evaluate (e.g.,={{$json["country"]}}). UnderRouting rules, add conditions for each desired output path (e.g.,value2forUSroutes to output 0,COto output 1, UK to output 2). - Utilize Fallback Paths: The
Switchnode'sFallback Outputdetermines where data goes if no routing rules are met, ensuring all data is handled and none is lost.
Apps Used
Workflow JSON
{
"id": "636e42ac-898f-4e0a-b986-200b2f1c03b8",
"name": "Smart Data Filtering and Routing with If and Switch Nodes",
"nodes": 24,
"category": "Operations",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 636e42ac-898f...
About the Author
DevOps_Master_X
Infrastructure Expert
Specializing in CI/CD pipelines, Docker, and Kubernetes automations.
Statistics
Related Workflows
Discover more workflows you might like
Universal CSV to JSON API Converter
Effortlessly transform CSV data into structured JSON with this versatile n8n workflow. Integrate it into any application as a custom API endpoint, supporting various input methods including file uploads and raw text.
Instant WooCommerce Order Notifications via Telegram
When a new order is placed on your WooCommerce store, instantly receive detailed notifications directly to your Telegram chat. Stay on top of your e-commerce operations with real-time alerts, including order specifics and a direct link to view the order.
On-Demand Microsoft SQL Query Execution
This workflow allows you to manually trigger and execute any SQL query against your Microsoft SQL Server database. Perfect for ad-hoc data lookups, administrative tasks, or quick tests, giving you direct control over your database operations.