Filter Data by Condition in n8n

Difficulty
1/10
Tags
EssentialsFilterHTTP RequestSplit OutConditional RoutingJSONArrays

When processing data, you often need to narrow down results to only the items that matter. Maybe you want to find high-value orders, active users, or products that meet specific criteria.

The Filter node evaluates each item against conditions you define. Items that pass the conditions continue through the workflow. Items that fail are discarded.

In this challenge, you will filter products to find only those worth featuring - items that are both affordable and highly rated.

What you'll practice:

  • Using the Filter node to keep only matching items
  • Setting up multiple conditions with AND logic
  • Understanding how non-matching items are discarded

Your Task

  1. 1Copy the exercise below
  2. 2Paste into your n8n editor (Ctrl+V)
  3. 3Solve it — use hints if you get stuck
  4. 4Check the solution when done

Fetch products from https://dummyjson.com/products?limit=10 and filter them to find "featured deals" - products that meet BOTH of these criteria:

  1. Price is less than 20
  2. Rating is greater than or equal to 4

Example product structure:

{
  "id": 1,
  "title": "Essence Mascara Lash Princess",
  "price": 9.99,
  "rating": 4.94,
  "category": "beauty"
}

Expected result: Only products meeting both criteria pass through. All other products are discarded.

Hints

  1. Add a Manual Trigger node to start the workflow
  2. Add an HTTP Request node to fetch from the URL above
  3. The API returns a products array, so add a Split Out node with Field To Split Out set to products
  4. Add a Filter node after Split Out
  5. Add your first condition: set the left value to {{ $json.price }}, select Number > is smaller than, and set the right value to 20
  6. Click Add condition to add a second condition: set the left value to {{ $json.rating }}, select Number > is larger than or equal, and set the right value to 4
  7. Make sure the Combinator is set to "AND" (this is the default)

Tip: Run the workflow and compare the item count before and after the Filter node. You should see fewer items coming out than going in.

Explanation

Why we need Filter:

The Filter node is your gatekeeper. When you have a stream of data and only want to process items meeting specific criteria, the Filter node lets you keep the items you need and discard the rest. Unlike the Switch node which routes items to different paths based on values, the Filter node makes a simple pass/fail decision - matching items continue, non-matching items are dropped.

How conditions work:

Each condition compares a value from your data against a threshold. The Filter node supports different data types (string, number, date, boolean) with appropriate comparison operators for each. When you have multiple conditions:

  • AND (default): ALL conditions must be true for an item to pass
  • OR: ANY condition being true lets the item pass

How the solution works:

  1. Manual Trigger: Starts the workflow
  2. HTTP Request: Fetches 10 products from the API (returns 1 item with a products array)
  3. Split Out: Set Field To Split Out to products to convert the array into 10 separate items
  4. Filter: Evaluates each product against both conditions using AND logic

What happens to non-matching items:

Items that do not satisfy both conditions are simply discarded. If you need to route non-matching items to a different branch for separate processing, use an IF node or Switch node instead - those nodes provide multiple outputs for different outcomes.

Copy the Solution

Paste into n8n with Ctrl+V to compare with your approach.

Login to see the exercise

Create an account to access challenges and track your progress.

Log in to see exercise