How to make a things value the result of multiple things

How can I set up a database entry to be the result of multiple other entries?

For example, a Database entry named ‘Grand Total’.

Grand total should update from (‘Source A’) + (‘Source B’ * ‘Value A’) + ('Source C * ‘Value B’) etc…

Ideally id like to do all of this math hidden away, and it just simply update the database entry and then i can read out that final value where its needed.

The only way I can think to do this now is to create an input (input 1) that is (‘Source B’ * ‘Value A’) Then another input (input 2) that is ('Source C * ‘Value B’) and then lastly a final input (input 3) that is ‘Grand Total’ = ‘Input 1’ + ‘Input 2’ + ‘Input 3’…

This just doesn’t seem practical though, i feel like there is a better way.

I went about this as mentioned. Using inputs to total up the values then using a workflow to add up all of the inputs into the grand total which works to some degree but it doesn’t seem like a good solution. As this only works for the page with the inputs. So if these values get adjusted on any other page, the Grand total is no longer accurate until visiting the page with the inputs to rebalance the grand total.

Im going to investigate some of the lessons based on shopping carts to see if i can figure out a solution as it seems shopping cart logic would be similar.

Math is a bit of a challenge on Bubble, especially when it has operations within brackets.

What you did is a fair hack, I’ve done that a few times too. But it restricts you to the frontend elements.
Instead, you could do the math within a ‘execute Javascript’ workflow action and set the result of that as the Grand Total’s new value.

This seems to be a decent tutorial: How to run Javascript from an action in Bubble

Ranjit | Blur Apps

1 Like

Thank you very much for this input and the tutorial.

I will investigate this tomorrow and report back with my results!

1 Like