I’m trying to filter a list by a list. My use case is that my datatype/table in the database called items has a field called “Tags” which consists of a list of tags (tags are also a datatype/table in my database. italicized so you can tell when I’m referring to the datatype/table).
On the UI, you can select which tags you want to filter by. Every time you add or remove a tag, it updates the state variable called “Selected Tags” which consists of a list of tags.
The data source for my repeating group is a list of items.
I want to filter my list of items by using the field “Tags” (which refers to the datatype tags and is a list itself). The logic I want to run is to only show the items whose “Tags” are included in “Selected Tags” (show only tags that are selected) but am unable to because Bubble’s not letting me filter a list with a list. Any suggestions?
After your repeating group’s data source, do
:filtered, then the
Advanced: constraint and do “This item’s Tags intersects with [your Selected Tags list” :count > 0" So if more than 0 common tags are found in both it will show that item. If you wanted a minimum of 2 tags to be in common you would do :count > 1.
In your Repeating group’s search use the constraints as much as you can to narrow down the search (it’s a server side search), then use the :filtered to get the ones where the tags are in common (:filtered is a client side operator so it downloads all the results from the search then filters it further on the client side, so keep the list as short as possible it has to filter)
awesome got this to work but one thing I’m seeing now is that by default when no tags are selected, my RG is empty (regardless of if I choose to ignore empty constraints or not). any suggestion why that would be?
Are you doing “ignore empty contraints” on the :filter not just the search constraints?
okay inside the advanced filter after the “This item’s Tags intersects with [your Selected Tags list” :count > 0" do
or [your selected tags list]'list of Tags is empty
This topic was automatically closed after 70 days. New replies are no longer allowed.