Forum Academy Marketplace Showcase Pricing Features

Conditional Filtering: Filter only when a tag is selected

Completely new with Bubble here, sorry if this is basic.

I have a RG with books in them. Each book has different levels of categories that they can be filtered with. The filters (categories) are in the form of tags and multiple tags can be selected. And there are two levels of tags - Level 1 and Level 2. The moment a tag is clicked, I have a custom state that adds the category value to the custom state ‘selectedL1’ or ‘selectedL2’ depending on which level of category was selected.

I have then filtered the RG data source such that only those books are shown whose list of categories/tags intersect with the tags in the custom state for each level.


The problem here is that if none of the tags of Level2 are selected, then I just want filtration to be done on Level1 tags. So if the custom state does not contain any tag for a given level, then filtration should not happen for that level. Filtration should happen only when a tag is selected.

Example: If i have selected ‘Antifiction’ in L1 and none in L2, I want all books tagged to L1 be shown. If I have selected ‘Antifiction’ in L1 and ‘History’ in L2, I want the list to be filtered for both. But right now if i do not select anything from Level 2 i do not see any books since the custom state for L2 ‘selectedL2’ is empty and the filter does not return any value as both the filters are applied.

I need to add another level of category after this so I would really appreciate if someone could guide me here.

Here’s my read-only project link for you to understand better in case I wasn’t clear here:

@SerPounce I know you’re a guru with repeating groups and filters, any ideas on this one?

I would probably default to having a custom state on the repeating group for each combination of level filters. I’m away from my computer at the moment, but I’ll think about it a bit more.

1 Like

See that “Ignore empty constraints” checkbox?

1 Like

What Keith said.

1 Like

Thanks for the response Keith and @SerPounce

I did check the “Ignore empty constraints” box but in vain. There’s virtually no change in the preview and everything works as when the box was unchecked.

Could I be missing something else? Thanks again!

Thank you Andrew for the reply and bringing more help!

I did think of having multiple custom states that show or hide the RG based on what’s selected, but with each new level the states would increase non-linearly and I thought maybe it’s inefficient and will lead to slowing the site down… Let me know if I’m worng? Thanks again!

Try using conditionals to change the data source.
So, condition 1 says if L2 is empty then use the first search.
Condition 2 says if L1 is empty then use the second search.

1 Like

Yes! it worked. Didn’t know that was possible. Thanks a ton!

1 Like

Awesome, glad you got it sorted.