In my repiting group the listings have prices from option set for example: up to 10, 10-50, 50-100 etc. How can I make sorting and flitration of repiting group by these option set?

In my repiting group the listings have prices from option set for example: up to 10, 10-50, 50-100 etc. How can I make sorting and flitration of repiting group by these option set?

You can assign a number attribute to those prices and sort the RG by the number

How to sort option set type?

As far as I know, there is no filtering by option set values

use the operator: sorted
as in the picture

there is no set option in the sorted list

okay I think I get your point, the solution I sent will only work if the repeating group is displaying option set, I think in your case options set is only a data field in the listing datatype

right?

Yeah, that’s what I mean.

Cases like this, where the field used to sorting is an object like a Option Set or even another Data Type, needs to use plugins like List Shifter (free in the past but now it is part of the paid plugin Floppy).

1 Like

Have you tried using a dropdown with price values to filter your repeating group based on the selected option?
Or are you trying to create a separate repeating group for each price?

I have a repiting group with companies with the price from the option set described above, and I need to configure sorting by these prices

I haven’t done what you want to do.

I did set up a repeating group that is filtered by a slider for low to high price. But that uses the database for the prices. This is a pretty simple way to do the filtering.

I did ask Perplexity about your idea. It said it can be done and gave me a breakdown of how to do it. You would also need to have a dropdown or something similar to let the user choose the filter. It did however think the slider method using the database was the most straightforward way. It’s a complicated process, so I’ll let you get the detailed instructions from there if you’re interested.

From what I can understand, what you want to do (from what you’ve explained) is you want a list of companies that either sell products within a certain range or offer services within a certain range? Either of these can easily be set up with the slider method using the database.

Then again, I’m not exactly sure what your use case is. It may be something I’m not understanding.

In Bubble, database queries cannot be sorted by values on related fields.

So if you need to sort large amounts of data by a related field, then there is no alternative than to add that field directly to the Datatype itself.

So, in your case, you’ll need to add the Price Amount from the Price Option Set directly to the Listings datatype as a number.

Then you can sort by that directly on the DB.

If you don’t need to do the sorting on the DB itself, and can do it client-side instead (i.e. you’ll only be sorting a small amount of data) - then it’s very simple with just a few lines of JavaScript.

Or, you can find some existing plugins to do client-side sorting - but in my opinion those are overly complicated in most cases.

2 Likes

Interesting. Thank you.

If you have a dropdown that is populated by an option group…

and then set a constraint on the repeating group based on that dropdown. Are you saying that won’t work?

this is what I need to realize

I’d really appreciate it if you could help me.

At first look…

this doesn’t seem complicated, unless (I’ll mention that in a minute).

The newest would just filter the repeating group by the created date.

I would add 2 number types to the data. 1 would be for the lowest price. The other would be for the highest price.

You could then filter the repeating group based on these prices.

As far as revenue, this is where I said it could get complicated. IF the highest revenue and the lowest revenue is a fixed number, you could add that to the database.

IF the highest revenue and lowest revenue are always changing based on different factors, this could possibly be another data type connected to your main data type.

So, everything would be simple to set up, but the highest revenue and lowest revenue would depend on how you calculate that, if you do.

Added: If your lowest revenue and highest revenue are a fixed number, that’s even easier.

Just add a data type for the lowest revenue, which is a number, and the highest revenue, which is a number. You could then just sort the repeating group based on this.

This would be the easiest. But, if, as I said, this is calculated daily or weekly, etc., it would change how you set up the lowest and highest revenue.

Let us know if you run into any problems.

Yes, I’m saying that won’t work.

Although you’re talking about filtering - which can be done client-side with an advanced filter.

I’m talking about sorting - which can’t be done at all (without custom code or a plugin).

The only way you can do this on the DB query itself (without duplicating the sortable attribute as its own field) is by merging multiple searches - i.e. search for items with price 1 merged with a search for items with price 2, then price 3, and 4 etc. but that’s not practical for more than 2 or 3 Prices).

1 Like

Several people have already told you what you need to do.

You need to add a ‘Price’ field (number) to the Listings datatype.

(or you can use some custom code to do the sorting client-side, but for that to work you’ll need to load ALL listings that match your constraints to the browser before sorting them, so won’t be suitable for large amounts of data).

It’s simple to just add a number field to the Datatype, and is the only/correct scalable way to do this in Bubble.

1 Like

Thanks, Adam.

After a couple of years of learning Bubble and having accomplished a lot, there’s still a lot I have no idea about how it works.

I do know it’s a great platform, where you can do virtually anything you want with little or no code.

2 Likes