# Filtering contacts where a boolean field is null

**URL:** <https://forum.mautic.org/t/filtering-contacts-where-a-boolean-field-is-null/17151>\
**Category:** General Discussion\
**Created:** [November 25, 2020, 5:39pm UTC](https://forum.mautic.org/t/filtering-contacts-where-a-boolean-field-is-null/17151 "2020-11-25T17:39:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pwned555](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/pwned555/32/3848_2.png) [@pwned555](https://forum.mautic.org/u/pwned555)\
**Post date:** [November 25, 2020, 5:39pm UTC](https://forum.mautic.org/t/filtering-contacts-where-a-boolean-field-is-null/17151/1 "2020-11-25T17:39:21Z")

</div>

I’m not sure if this is a bug or if I am doing this wrong but logically it doesn’t make sense to me.

- No filter there are 12 contacts in my list.
- opted\_in:1 I have 2 contacts.
- opted\_in:0 I have 6 contacts.

The remaining 4 contacts are correctly the ones with nothing selected for the opted\_in field.

- opted\_in:\_ returns all 8 contacts with any value for opted\_in
- !opted\_in:\_ returns no contacts
- !opted\_in:1 only returns the 6 no contacts
- !opted\_in:0 only returns the 2 yes contacts
- (!opted\_in:0 !opted\_in:1) returns 0 contacts
- (opted\_in:1 OR opted\_in:0) returns 8 results
- (!opted\_in:1 AND !opted\_in:0) returns 0 results
- !(opted\_in:1 OR opted\_in:0) seems to spin and not finish, but if it actually does finish it’s returning 8 results

These no value contacts seem to be ignored whenever I try to filter on the opted\_in parameter but appear when I filter on any other parameter.

Thanks,

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [November 26, 2020, 9:49pm UTC](https://forum.mautic.org/t/filtering-contacts-where-a-boolean-field-is-null/17151/2 "2020-11-26T21:49:57Z")

</div>

If some value is empy, it will be picked up if you look for ‘empty’

For example you can have 3 kinds of status for visitors based on ‘date last active’

1. Active in the past 30 days (date \> -30 days)
2. Active longer than 30 days ago (date \< -30 Days)
3. Never active (date active = empty)

In other words ‘no value’ is not zero.

I hope that helps  
Joey

---

<div class="post-metadata">

**Author:** ![pwned555](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/pwned555/32/3848_2.png) [@pwned555](https://forum.mautic.org/u/pwned555)\
**Post date:** [November 26, 2020, 10:25pm UTC](https://forum.mautic.org/t/filtering-contacts-where-a-boolean-field-is-null/17151/3 "2020-11-26T22:25:27Z")

</div>

Thanks for the reply I don’t fully understand what to filter for. In my scenario I want to do a quick filter at the top of the Contacts grid. I have a boolean field (1/0/null values), and I only want to return contacts with null values when I filter. How would I do this? How do I look for empty values in the top filter? I’ve tried every combination I can think of (even doing where not 0 and not 1, you would think that would return the empty values but it doesn’t).

It might just be the syntax for that filter that I’m missing, but I don’t know how to tell it to search for empty. I tried opted\_in:null, opted\_in:empty, opted\_in: with a space after as well as all the combinations in my post above. None of these return the corresponding 4 contacts who have not selected yes or no yet for the opted\_in field.

Note: This is the filter on the top right of the main contacts page where I’m trying to add these values.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [November 27, 2020, 5:55am UTC](https://forum.mautic.org/t/filtering-contacts-where-a-boolean-field-is-null/17151/4 "2020-11-27T05:55:17Z")

</div>

Oh… in the contact grid? Then forget what I said, I was talking about the segment filter sorry.
