Data Table Filter

I am having trouble with getting the Data Table Get Filter to work. I want to return all rows where I want to specify for instance Name equals ‘John’ OR ‘Bill’ OR ‘Frank’. What is the right syntax to specify OR in the value as an expression and return all rows that contain my specified values?

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

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

Well hello there,

It depends on how you fill the filter i guess. What’s the node before, how do you start the filter (Telegram, webhook, chat etc.). Do you use any condiation or all conditions. And what is the expression in the condition that you use.

Regards,

Well hello Michlel, that is exactly the question, what is the expression that has to be used. Tried ‘Mike’ OR "‘John’, did not work. Tried ‘Mike’, did not work. Tried Mike without quotes. That works. Tried Mike|John, did not work. Configured the Data Table node for the above choices for ‘equal’ and ‘contains’. he node before should have no bearing. At this juncture, I’m just trying all combinations without luck by being on the actual Data Table configuration screen and clicking ‘Execute Step’.

Hi,

So you are entering the expression yourself. Let me test some things and see if I can reproduce it.

Regards

If I understand you correctly, Any Condition is like an OR and All Conditions is like AND

Hi,

So I setup a simple table with a column named Name and colum named Value. I have put a couple of names in it, and some numbers. Then I made this simple workflow.

And then tested it. If I put mark in the chatbots I get back mark.

I don’t think I get your problem at this point (not native english) so some screenshots or something would help.

I see it doesn’t display correctly so I’ll upload a screenshot.

Hope this helps.

1 Like

Michiel, thanks for trying. Challenge is how to retrieve records that are ‘John’ OR ‘Mike’. Not 1 value like you have here such as ‘John’.

Yes I want to use OR. I want to retrieve all records where ‘Name’ eq ‘Mike’ OR ‘John’ for instance. Next run it might be ‘Mike’ OR ‘John’ OR ‘Joe’. I cannot hard code an arbitrary number of Any Condition.

A simple SQL statement that explains what I am trying to do if that helps:

SELECT * FROM Customers
WHERE Name = ‘John’ OR Name = ‘Mike’;

The string Name = ‘John’ OR Name = ‘Mike’ is built dynamically.

The next run it might be Name = ‘John’ OR Name = ‘Mike’ OR Name = ‘Joe’.

I do not not beforehand how many ORs there will be, it is specific to each run of the flow.

Unfortunately data tables are meant for very light use and some basic filtering. If you want to use more complex queries, you’ll need to use a proper database like mysql or postgres (supabase), etc.

In my opinion my use case should fall under very basic filtering. This is a very common use case and a full database might be overkill for the 20 odd rows of data I have. But with Data table still evolving, we have to see what happens down the road. Thanks Wouter.

But that does work m8. If you enter the names as condition, you will get the results your looking for.

And if I change those to something else. The second value is unknown, it returns only mark

If this is the answer you are looking for. Then here you go. But I guess you want to get the values from somewhere else. A whebhook, chat or something like that.

Is this what you wanted, or do you need something else.

Regards,

Sorry,

I missed this thread of yours. It’s a simple DB. So you need some code to get your result. Just get all the rows you have, and use a node ccde to filter on the names you enter. I guess there’s no real other option that I can think of.

Regards.

No, I do not know before hand how many how many names I will have for each run, sometimes it might be 1, sometimes 10, sometimes 15 so with this approach i will have to add a lot of conditions for one field, not very clean

Thanks for trying. Yes there are other ways and not so clean. At the end of the day, if there a data table, we should be able to do basic filtering like the one I need. Hopefully down the road. Have a great day.

If you only really deal with a few records (up to 1000), then I would suggest you just read all records and then do complex filtering using a Code Node.

Yes thought about doing that. Only reason to open this thread was to find out whether I was missing something in terms of filtering. Many ways to skin the cat, one being not use Data Tables at all. Thanks for the feedback.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.