Filter node doesn't filter values that are smaller than, but does filter values that are larger than

Describe the problem/error/question

I am trying to filter a set of job postings based on the number of employees at the company. I am doing this by passing it into a filter and using these to conditions:

Employee count → Larger → 50
Employee count → Smaller → 50

Only, the Larger filter seems to work:

Larger

Smaller

Please look at the number of kept and discarded items.

It doesn’t make sense to me.

What am I doing wrong?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • **n8n version:**You’re on 1.18.2
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker
  • **Operating system:**Digital Ocean

@LinkedUp_Online , the outcome seems to be valid to me. You are using OR comparison operator, and null is considered always smaller than 50. Thus, when you use “Smaller” comparison it always returns true. Why null? Because you do not have the property “company_staff_count” in your data set.

@ihortom I don’t think I understand.

Either statement condition can be true for the filter to pass an item right?

So if I set companyEmployeesCount < than 50, how can this item be passed as true?:

image

I also changed the filter so that it doesn’t return null if the variable is undefined:

Or can undefined also evaluate smaller than 50 to true?

Thanks for your help! :slightly_smiling_face:

@LinkedUp_Online , what is the property “company_staff_count”? From what I see, it does not exist, hence it has the value of null. As such, it is always smaller than 50. Therefore, when you use the condition $json.companyEmployeesCount < 50 OR $json.company_staff_count < 50 it will always return true. If you remove OR $json.company_staff_count < 50 it should work as expected.