How To Sort Based On A Calculated Value On The Screen?

I have a search that’s conducted and the results of the search produce a calculated value (ex. a price) and I’m trying to sort the data on the screen from lowest price to highest price.

How can this be achieved?

It doesn’t appear Bubble can sort calculated values yet?

I thought of sending a JSON to some sort of web service if not, and having that send back the sorted version, but not sure a service that would do this? or if this is even possible??

1 Like

I don’t quite understand your issue from the description, but it sounds like you have Products (or something) that do not have a fixed price, but where the price comes from a database lookup? Is that correct?

And so, you probably have an element inside of a repeating group that displays this info, correct?

You need to get your values into a list. But, there’s actually no way to do that in vanilla Bubble

There’s so much thrashing about this (and really stupid solutions like certain plugins I will not mention here) in Bubble that I built a plugin for it.

(The reason people do absolutely stupid things with respect to lists and repeating groups and such is that the right tools don’t exist.)

There’s a new version that can help you do exactly what you need to do, BUT it will take some explaining and I’ve not yet created a good video overview of how you should handle this use case, but I may get to that this afternoon.

Check out List Shifter over here:

@anil see this.

Thanks @keith and actually we don’t have the values in the database.

Rather, they are calculated values based on the information inside the database.

I.e. a train ticket price is $100/mile travelled.

So between two points, bubble calculates distance, then multiplies that by the ticket price/mile to result in the calculated value displayed on the screen.

So we’re trying to sort from low to high ticket prices! But we can’t do it because there is no ability to sort by the value that’s being displayed on the screen.

@JustinC, I have been struggling with a very similar problem through this thread:

The commonality of our issues is Bubble’s limitation to only allow sorting on the RG’s thing (with some limited exceptions that are covered in the thread). The only difference is that you are looking to do a calculation, while I am trying to access fields in a child thing. Either way, I’d be happy using an expression to do the sort, but Bubble doesn’t allow… for now.

My goto solution for my specific case is as of now to have two RGs. The first one with Gigs created after the user’s last visit, visible only if not empty. The other one the rest opposite of of RG 1. Both RGs sorted on Gig_Status “Nigel” style.

The downside being having to duplicate my extensive filtering.

Please stop me now if I’m heading in a totally wrong direction!

Changed my mind. I will go for the ugly solutions of having copying the sort number from Gig_Status to the Gig when the admin changes the Gig’s Gig_Status. :flushed:

This topic was automatically closed after 70 days. New replies are no longer allowed.