I have run into a seemingly trivial issue. I have a RG that displays a list of tasks belonging to a specified category. I currently have a “filter” bar above the RG to change the filter applied the to RG. The filters are based off of an Option Set containing various task statuses: open, pending, complete, n/a, etc. The issue I am running into is, I have been asked to put together the equivalent of an “or” query. I need to filter for multiple options in the option set. I do not see any way of structuring the “:filtered” parameter to accept an “or” operand on the status value.
Is this possible?
Should I just go back to a text data type (would be a really big PIA)?
This is possible using an ‘Avanced’ filter option.
In the filter panel, click ‘Add a New Constraint’ then instead of selecting ‘Status’ from the dropdown, select ‘Advanced’ (right at the bottom of the drop down).
Then choose ‘This Task’ - ‘Status’ - ‘Is’ - ‘Whichever status you want to filter for’
Then select ‘Or’ and build the same expression again using a different ‘Status’
Hey there @adamhholmes… I have a similar situation to @pat3 (trying to filter an RG by options in an Option Set. In my filter bar, I’ve got a Multidropdown where users can specify multiple options from the Option Set that they’d like to search for. The one difference between Pat and me is my Data Type can have a list of options from the Option Set). I tried following your instructions above…
Pat: Advanced > This Task (Data Type) > Status (Option Set name)
Me: Advanced > This Artwork Details (Data Type) > Subject (Option Set name)
Advanced > This Artwork Details (Data Type) > Category (Option Set name)
Here “Is” does show up as an option. Category is also an Option Set, but each Artwork Detail can only have one Category associated with it (drawing, photography, etc.), whereas each Artwork Detail can have a list of Subjects (eg. a photograph of a Seattle block can have multiple Subjects: “City Life”, “Architecture”, “Fashion”). I did try “Contains” instead of “Is”, but that didn’t seem to work.
How do I approach this when one piece of artwork can have multiple subjects ?
Hmmm… It seems to be trickier with list fields… I’ve been messing around with this for the last hour and I can’t find a simple way to do it…
I’ve got it to work using the ‘intersect with’ command along with a count in an advanced filter:
This artwokdetails – Subjects – Intersect With – MultiDropDown Subjects – Value – Count >0
This works fine, but it doesn’t seem to be ignoring any empty constraints, meaning the RG is empty until subject values are chosen from the dropdown.
So I’ve then had to use a conditional to have a different data source (without the filter) when no option has yet been chosen from the dropdown.
Again that works fine but is does seem like a fairly complex way to achieve what should be a simple function. Perhaps some one else knows a simpler way to do it that I’m overlooking?
The above method works if you want results shown that contain ANY of the subjects selected. If you want to show only results that contain ALL of the subjects selected then you’ll need to find a different solution.
I’ve found a simpler solution, but it only works if you want only Artwork Details that contain ALL the subjects selected in the multidropdown to be shown in the RG.
Just use an advanced filter:
This Artwork Details — Subjects — Contains List — Subject Multi Dropdown’s Value
A couple tips on the above:
With “intersect with”, you can modify it a few ways…
If you want it to ignore empty inputs, then say :count has to be >0 and list a intersects with list b…
You can specify the overlap by sticking a count at the end. Count >0 means at least 1 intersect. Or if you want all of the selected subjects to match, then set the :count to the # of selected subjects.
Regarding the original question at top (searching with an "or), note you can achieve this search without filters by combining multiple “do a search for” with the :merged function. This effectively creates the “or” and keeps the search server side (ie, faster).
Requiring that Artwork Details contain ALL subjects selected in the multidropdown isn’t going to be realistic. As long as at least one selection in the multidropdown is among the subjects associated with a piece of art’s Artwork Details, that piece of art should show up in the RG.
As you suggested, I’ve entered…
Advanced Filter – Artwork Details – Subjects – Intersect With – MultiDropDown Subjects – Value – Count >0
… and, like you said, it works fine except the RG is empty until I select a subject from the dropdown (it doesn’t ignore empty constraints). This isn’t ideal. I need to figure out how to address that.
Hey @ed727… this is what I’ve done based on Adam’s suggestion. Is this what you were suggesting, too? What would you suggest I do differently?
You’re using merged with in the way that I would have.
Regarding the issue of the empty constraint, delete the “Category is in…” constraint, and in your Advanced filter try having it read… “Advanced: Multidropdown Subject’s value:count is 0 or Multidropdown Subject’s value intersect with This Artwork Details’s Subject: count >0”
(I retained the “Category is in…” piece because that’s for filtering by the ‘Category’ parameter - where a piece of art can only have one Category specified. The combination of that and your solution for the ‘list’ parameters is what I needed)
Glad it worked! I learned the method through others on the forum. It’s one of those things that you’d think would be simple but isn’t at all obvious. Maybe one day Bubble will move the “list to list” search server side and establish a simpler method.