Forum Academy Marketplace Showcase Pricing Features

How To Query or Filter Field of Type List Based on Checkboxes

I have a field in my DB that is a list of text. It will have one of four options (at the moment).

I put four checkboxes on my UI to allow the user to filter search results based on the checkbox. When none are checked, I want it to show everything. When one or more are checked, it should be an AND condition. When one or more is checked, they populate a state list of the page.

I have searched this forum, the web, and YouTube on how to accomplish this, but still haven’t found anything that gets me to my objective. Some questions in this forum with the same idea have gone with zero responses and been closed.

I’m going to try to do an intersection of the record’s list field with the state list I’m composing, but it looks like that has been tried and did not work.

So how do I filter a series of records based on having a list of text that should intersect with a list of text?

Maybe by filtering under this condition: The number of intersections (between the field in DB and options selected by the user) must be equal to the number of options selected by the users.
This filtering event should be triggered only when the list of options selected by the user is > 0.

1 Like

The way I have done this is by having a custom state that holds a list of the things I want to match on. eg is that list could be “red, blue” or “red” whatever - the checkboxes control the contents of that list. So your query criteria is something like " Colour is in my custom state list of Colours"

Screenshot 2021-11-01 at 21.12.26

The second part is to check this box in your query “ignore empty constraints”. This is what lets you “show everything when that list is empty”

Screenshot 2021-11-01 at 21.06.05

1 Like

Check this out @cryptoinwestorka

Please look into it Noqodesolution | Bubble Editor

Hey @cklester

have a look at my thread. I have listed a lot of other threads that touch on the subject of finding db objects based on the list. They helped me solve my filtering situation.

I have used intersection for my use case when searching for a DB object that has a list as a value on the property.

You can have a look into my app and then test the filtering on the front end. Click on the calendar element in the app and look at the conditional tab. Maybe it helps you figure your case out. My case probably could be optimized, but so far it does the job.


Thank you for the help, y’all! I finally kinda wrapped my head around searches with filters. Once I added the :filter to my query, I was able to use that Advanced stuff to perform an intersection with the state list (triggered by the checkboxes) and get the list filtered!

One of the things I had to condition was what if the record itself had an empty list, meaning it applied to all cases. (I could enforce checking all boxes in the record if all applied… and maybe I should… It’s only 4 boxes… so that if no boxes are checked, that record would never show up in a search where none of the checkboxes are checked in the state list. Hmmmm… what’s best practice? I would say check the boxes that apply…)

Is there a better free search algorithm out there (currently on free plan building a MVP)? The Fuzzy Search & Autocorrect one is giving me garbage output. (A search for “wall” returns ONE record, while a search for “walle” returns FOUR. Wat?! Very bizarre… but I am new to, so who knows?)