Forum Documentation Showcase Pricing Learn more

What am I doing wrong in setting up this filter?

Hi everyone. Hoping one of Bubble’s finest can lend the assist.

I am working on a marketplace app and I’m trying to setup some filters. Screenshot below of the page. When the page loads it is set to display the products in the users’ “favorite categories”. In this case products in “electronics”, “clothing”, and “sports & outdoors” appear. Super, that works.

1.) Now when you search by location, it works like magic too, filtering to only products in Boston.

2.) Then when you apply the category dropdown filter on top of that it further filters it to “Electronics” products in Boston. Great!

3.) But then when I go to apply my third filter it does not work when it seems like it should. In this image I have the “Price low to high” checkbox checked and it should put the purple screen laptop ahead of the darker screened image, but it doesn’t. In fact, nothing happens when I click either checkbox.

Here is how I have it setup – through conditionals. Is there some cardinal filtering sin I’m committing? I feel like I have the logic correct, but I must be missing something obvious.

I’ve been bubbling for a while, but one of the areas I still have to master is filtering. If any of the Bubble experts can chime in that would be super appreciated!

I think you are focusing on search filter but what you seem to talk about is the sort order.
You should set Descending using dynamic value “Checkbox” is checked

@marktuff, is the sort order the only thing you are changing in the search?

@Jici that doesn’t work either. Besides, the way I have it setup in the conditional where “checkbox (low to high) is checked” should accomplish the same thing. It works perfectly when the filtering is based on two variables, but as soon as the checkbox becomes the third variable, it isn’t working.

@Eli, yes.

I also tried writing the expression after “Search for Products” and using “:sorted by” and selecting price that way, but that is not working either.

I wonder if other conditionals I have on the RG is somehow blocking this from occurring. I doubt it though as those three elements (dropdown, checkbox, location searchbox) are the only ones that would trigger this data type search.

Can you share screenshot with the checkbox setting? Also, is the price field is a number field type?

The price field is a number.

Not sure what you mean by checkbox setting?

@marktuff Try creating a custom state ‘yes/no’ and simply making the Descending parameter in the initial search dependent on that state. Then simply set the state to ‘no’ when you click the checkbox and it should dynamically change the sort order without having to create a condition and a new search.

I mean the search and sort part with the checkbox used in it.

Would that be the last screenshot in my original post?

That is the conditional I’ve set on the RG, that includes the checkbox as the second part of the expression.

Ok I undestand your setting. The first thing is that you should also use a dropdown for the Price low to high and High to low to reduce issue if user select both. You can also try to use state like @eli suggest but it should work without that. And yes, it’s possible that you have conflict between conditionnal (this is what I think). In debug_mode, you can see which conditionnal is activated (or not) by inspecting RG

@marktuff I kind of ignored your initial question (sorry) but there’s nothing wrong with your search. That should produce the result you are looking for. For some reason that conditional isn’t being triggered which is why I suggested the dynamic sort order on the initial data source as it’s more easily maintained.

Do you have other conditionals set? Remember the last conditional that returns true is the one Bubble will use so it matters what order the conditionals are in.

Like this?

Still not working. Arg.

No, not the sort by field, the Descending field. You should be able to set that dynamically.

No worries @Eli and I thought so too, which is why I’m miffed.

It must be something with conflicting conditionals…

Yes, a lot lol. Almost 30 on that RG. I must be being terribly inefficient. What would be the better way to set this up.

Alas… advanced filters and states, the final frontier.

Hey guys, I have to disappear for a bit but will return this afternoon. Thank you for the help thus far!!

You don’t need advanced filters or something like that.
I think that you should reduce the number of conditionnal and also use Ignore empty constraint to reduce the number of conditionnal.
You should delete one of you sort price checkbox (keep only one, for example, High to low, if this is not checked, this mean this will be low to high… and this way, you can use the checkbox directly into your Search setting instead of having conditonnal).

Did you check using debug mode which conditonnal is applied?

@Jici I think I need some additional schooling in conditionals, constraints, and the debugger.

I checked and it appears the condition works. But also other conditions are showing as valid too. I thought that because the condition that I want to trigger requires three variables to be true, then that would be the one to trigger, as opposed to those that have fewer than three. Shouldn’t that be the case, or am I mistaken?

Here is a snapshot of the debugger report.

This is exactly your issue. This is related to conflict between conditions. I also think that you can do better by just using correct setting into your original data source “Search” by using ignore empty constraint.

Hi @Jici, can you walk me through this and why it is better? So when you have the checkbox ignore empty constraints on, it’ll search either or depending on what value returns, correct?

But I still need to make sure all the proper conditionals are triggered “when” to perform the correct search right? That’s where I’m heavy up front on the combinations of filters that can be used and I’m not sure if I can make that any more efficient, or I just don’t know how.

BTW. I might have figured something out, but need to do some additional testing and then I’ll return with the results.