What Would It Take To Sort By A Calculated Value In Bubble?

I understand that Bubble can’t sort by a calculated value on the screen yet.

I’m wondering what it will take to sort a calculated value in Bubble, possibly through the use of external API’s, or anything else for that matter.

There are so many applications out there that sort by calculated values, but this seems to be one of the very few sticking points at Bubble.

I’m also wondering if Bubble has any plans to sort this out so that we can sort some way, possibly by storing the values in a cache of some kind, and then sorting the values/entries in a repeating group from there?

Looking for any solution at this point, or assurance from Bubble that it’s being worked on, which would be a great thing to hear!

4 Likes

Hi @JustinC

I’m curious about this, I assume you have an idea on what you’d like to achieve here, can you give us an example of what you’re thinking because I reakon there would be a way, most of time there is!

Paul

2 Likes

yes this is a pain, if you search through the forums you will find previous threads. Advice seems to be to do your calculation then store it back to the database, but if someone knows a better way please tell me I’m interested too!

In my latest effort I was saved because I want to sort on the distance between two addresses. If you happen to be wanting this specific calculation, you can do that by sorting on the Address field and Bubble gives an option to sort on distance from another address.

2 Likes

There are quite a few workarounds for the various situations. Not all of them involve creating a new field on the database.

1 Like

I’d love to have a solution for this @NigelG currently totally stuck.

The values are calculated and displayed on the screen based on the inputs of the user.

Plane tickets depend on the distance flown between two points calculated against the cruise speed of the aircraft and further against the hourly operating cost of that aircraft, as set in the database.

The only values in the database are hourly operating cost and cruise speed and the 2 fixed_addresses (geo addresses) of the two points in the itinerary to calculate a distance.

So i’m trying to sort flight tickets, by the lowest to the highest, based on the user inputs.

How can I achieve this either inside or outside of Bubble??

@NigelG do you have any advice on this that you can offer? I am stuck.

Hi @eric1

If I understand correctly, you have managed to calculate the distance between two addresses. if so, may you please help me out with that, I have been struggling with getting the distance between two addresses right.

Convert the 2 addresses to geo addresses then use standard bubble functions to find distance between the two points. There are lots of threads on this.

1 Like

The issue is its running on 5000+ entries. Its not possible to re-save all of the calculated values.

So for each ticket (are they in the database too ?) you calculate something based on the distance and the speed & cost of the particular aircraft ?

So work out the travel time using speed/distance and calculate the cost ? And then sort on that ?

If you solve for 1 and sort on that … doesn’t the sort then work for n ?

So store the base “cost per hour flown” and sort on that ?

1 Like

The price her hour is in the database, yes, but that doesn’t help, because the current position of the aircraft is used to calculate the total flight time and ticket price.

So if you are requesting a flight ticket from NYC to London England and the aircraft is positioned in Chicago and has a home base airport in Milan, IT the calculations are as follows based on the distance/time*hourly rate of the aircraft -

leg 1 - Chicago to NYC (pick up client in NYC)
leg 2 - NYC to London (drop client off in London)
leg 3 - London back to home base in Milan Italy

All of the above is calculated by Bubble to get total distance and calculate it against the saved hourly rate for the aircraft. And at that point, it must be sorted from lowest to highest price.

Gotcha.

How many calculations would you need to make ? i.e. how many aircraft could make the trip.

Is it possible to do a high level sort to knock out aircraft that are in … say… Tokyo at the moment.

1 Like

Yes it would span outward from nearest to the departure city/airport, as that would result in the lowest price, but the total results can be over 5000 in the database, as you can get specific with the aircraft type and request a special aircraft that comes from, say, Dubai to NYC, NYC to London England, then back to it’s base in Dubai.

So all of the aircraft need to be eventually parsed and calculated and then sorted. It could be done in paginated format (just an idea) or 100 entries at a time, but it still doesn’t help because bubble can’t sort the calculated values it seems.

Any way I can get this done i’m open too - such as an api, or anything else. I just can’t figure this one out.

Hi @JustinC

I have been trying to get this right but have not come right. I tried many options for what you have mentioned above. This is one of my approach below. Please advise where I got it wrong.
image

I have saved the addresses using the geo-addresses.
image

Push out to Airtable/Parabola ?

1 Like

Parabola would work well, i agree, and I had tried them, but they suggested it wouldn’t be quick enough and isn’t geared toward such speed.

I will investigate Airtable - something tells me i’ll run into a speed issue here as well - I just wish that we’d have input from the bubble team on what this will take to achieve. Sorting by a calculated value is such a sticking point based on the forum posts and feedback.

@mxolisipn Here is what I’m doing:

1 Like

@NigelG besides writing back to the database I’m aware of pulling a value out of the repeating group using bdk plug-in (haven’t tried it.) What others? Seems like this would be a handy topic to build mastery of the workarounds.

I am using the bdk solution to great effect to sort on fields in a related data type.

1 Like

What is the bdk solution?

1 Like