N8n Filter szenarios for no match or no fail

Hi there,

I started with n8n recently more intense and I’m wondering if I found a chance for a custom node or if I just misunderstand the core concept. If you prefer video over text, here’s a short 4 minute video :slight_smile: Loom | Free Screen & Video Recording Software | Loom

Describe the problem/error/question

In a scenario where I receive a phone number and have a list of customers, I would like to check if the customer exists. if so, I want to add a note to this customer. If he does not exist, I would like to add an entry to the database and add a node to this new customer.

The problem is: If I use the “Filter” Node, it will either let pass 1 customer (good) or none at all. If none passes, the workflow stops.

The fastest solution I found was building a custom note; I just copied the Filter-Node, renamed it to Filter advanced and adjusted some configuration to output Result and Discarded + an indicator if all or none passed, but I’ve the feeling I’m just missing something.

Please share your workflow

See video please

Would be nice if you could tell me how you would achieve the scenario

n8n Version: 1.14.2
Running n8n via Docker and - locally in code.
OS: Windows 11

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

@Human371BetaRelease , you seems to have recreated the core node that already exists. It is called “Switch” and it can have as many output branches as you need.

Hi @ihortom , thank you for your answer.

Maybe I miss something, but the Scenario that I’m aiming for is not classical switch, becauses Switch - like Filter or If - runs on ItemsBase. I need to find out, if no entry matches my filter/if/switch, not if any matches.

I tried to recreate the code using Switch, but it feels like If or Filter:

  • I can achieve that the flow continues, if I match one entry
  • With If, I can also achieve, that the flow continues, if one entry does not match
  • I cannot achieve, that a flow only continues, if no entry matches.

I could achieve the last scenario, if I use a code node and compare the amount of items after the if-False with the one before the If. But then I could also directly use a CodeNode and drop the If/Filter/Switch at all. But I think CodeNodes are not userfriendly, I’m thinking about teaching n8n to Non-Coders and for such, the CodeNode should not be the default way to go.

@Human371BetaRelease , thanks for clarification. I think I got your problem now. Basically you want a condition when none of the items in the whole set matches.

Any node in n8n workflow works on each item in the dataset individually (one item at a time). To achieve what you want, the node would have to iterate the input data twice, which could be costly for a very large sets of data as your scenario is rather unusual. Thus, the first iteration would be a “waste of time” for most users.

Having said that, if there was an optional feature added to do the first iteration (all set parsed first) only when there is a need for it then that sits fine with me.

I guess you can raise it as a feature request unless someone from n8n team actually has a simple solution already. Otherwise, indeed, that first iteration could be done with extra nodes.

For example, no Code node involved in iteration for easier maintenance and comprehension:

1 Like