# Filter returns empty datascource

**URL:** <https://community.appfarm.io/t/filter-returns-empty-datascource/1591>\
**Category:** Bug reports\
**Created:** [January 16, 2025, 7:09am UTC](https://community.appfarm.io/t/filter-returns-empty-datascource/1591 "2025-01-16T07:09:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/daniel/32/2882_2.png) [@daniel](https://community.appfarm.io/u/daniel)\
**Post date:** [January 16, 2025, 7:09am UTC](https://community.appfarm.io/t/filter-returns-empty-datascource/1591/1 "2025-01-16T07:09:41Z")

</div>

I have a data source where I want every element in the database except two specific elements that are specified in a separate da source each. In my case one of the two “one” data sources does not have a value at the moment. When I apply the filter that should give me every element except the two, no elements is returned. Is this a bug?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/6/63f0b0fb4c39b2e3fbaecd1022685832bcc4377c.png)

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [January 17, 2025, 7:57am UTC](https://community.appfarm.io/t/filter-returns-empty-datascource/1591/2 "2025-01-17T07:57:15Z")

</div>

Hi!

What is the cardinality of the right-side datasources? In order for this filter to make sense (using the `Not equals` operator) the datasources on the right side must be either cardinality One, or they must have a single selected object.

In any other case: use operator `Is None Of`.

---

<div class="post-metadata">

**Author:** ![daniel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/daniel/32/2882_2.png) [@daniel](https://community.appfarm.io/u/daniel)\
**Post date:** [January 17, 2025, 8:05am UTC](https://community.appfarm.io/t/filter-returns-empty-datascource/1591/3 "2025-01-17T08:05:25Z")

</div>

The cardinality of both right side datasources are one.

In this case the database contains 6 entries of type “KP - Produktliste”  
“KP-Produktliste (Aktiv)” Has cardinality one and contains one element.  
“KP-Produktliste (Kommende)” Has cardinality one and contains no elements.  
The filtered result contains no elements.

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [January 17, 2025, 8:46am UTC](https://community.appfarm.io/t/filter-returns-empty-datascource/1591/4 "2025-01-17T08:46:45Z")

</div>

Hi,

I see. This behaviour has in fact been discussed years back, and was not concluded to be changed. The reason is that SQLs behave the same way, if the right-side return null/undefined.

Example:

```auto
SELECT * 
FROM tasks t
WHERE t.projectId <> (
    SELECT TOP 1 projectId 
    FROM projects 
    WHERE projectState = 0
);

```

If no record is returned in the subquery, the comparison towards `null` is not possible and there will be no tasks returned from the query.

Appfarm follows the same principle in this case, whether it is correct is a matter of opinion/definition. But, changing such behaviour may have major implications on business logic already defined with the current behaviour in mind.

So, you should change the business logic. For example: If you combine the right-side datasources into one (Aktive and Kommende), you can use operator `Not exists in`, which will produce a valid comparison.
