Hello,
I am building an app, where I am collecting data from the user. Now this data will be taken in a bubble database like excel or google spreadsheet and then use to perform complex calculations and show the output to the user in tabular format or a single value. What is the best possible way to do it in bubble?
Can you specify what kind of Complex calculations you’re looking to execute?
Using the composer you can easily make calculations. You will need to figure out the way to get the exact result you’re looking for but its certainly possible to do so. You can build complex calculation expressions with the expression builder when displaying data or saving it to the database.
Here is the issue… if you make, lets say, a table with data, where some of the columns are going to be displaying these calculations results, it might be a little too much consumption on your workload units on the longrun since everytime the table is loaded, the calculations are going to be recalculated, where as if the calculated result was already in the database you can just pull the result right into the table data and be much less resource-heavy.
What I recommend is if your users input data into a form, when you get that data saved into the database, go ahead and make the same calculations during that same workflow and save the results into the database, making it easier for bubble-s front end to pull data instead of calculating it.
If your users will modify the data after it has been saved you can recalculate every time they update the data, still would be much better than having bubble calculate every time a table is loaded…
If your data comes in part, some is user-provided and other is through API, just calculate once you have everything but always write it to the database if you can
Hey Thanks for replying. I am new to bubble so I am trying to understand this better.
Firstly, it would be great if you can explain more about expression builder and composer.
Secondly, I will talk about a scenarios and would like to know your views on that:
Lets say there is a table with four columns -supply, demand, net availability, cumulative availability and if month-wise data is available for supply and demand, how do I calculate the net availability and cumulative availability -(in excel, for net availability I would hv subtracted the two values and for cumulative availability, I wud hv added the sum of previous month’s net value with the current net data and calculate it for each month).
Thirdly, a very important advice I would like to take- If there is a long list of table and I need to add formula to one table and drag it for all tables, like we do in excel, how can that be done in bubble?
This is the expression composer

you can use it to build complex formulas, in this example im subtracting the Receipt from the Total Amount of an invoice. Everytime I load the table it will execute the calculation and display the result. Both Receipt and Total Amount are written manually into my database and then I run the calculation on those two fields. Similarly you can have the Supply and Demand written in your DB and then run your desired calculations.
In bubble calculations are built different from your used to way in excel but its the same math at the end of the day…
For the commulative it can be a little more tricy but ill give you an example with the kind of data I have
Lets say I want to sum the total amount of my invoices and subtract the total Receipt across all invoices to get the General Balance Due… I would do something like this:
First I do a Search of the Invoices where the Creation Date is Greated that 1 month ago (you can use a specifc month or a dynamic date range, you-ll have to dig a little deeper into dealing with date ranges)

Then Choose Each Item’s Total Amount:Sum

This is going to take each value on that Total Amount and summ it up.
Then I did Minus “-”

and repeaded the same seach with the same parameters, this is important for accuracy. But instead of Each Item’s Total Amount I did Each Item’s Receipt:Sum

This calculation took two searches. If I were to replicate this in a table, it would do two seaches for every row just to come up with this number so you can see how resource-heavy it can be, not recommended. But for a dashboard element where you display this sum it works great
As for your third questions, Im not sure what you mean. in bubble you can copy the column and paste it in every other table you need. if the table data source is the same Thing as the other tables the copy paste would just work right away. If it is not the same thing you might have to do some expression adjustment but the formula would still work once you fix it. You cant drag a formula like in excel. But in the table element, once you add the formula to the top row, each row will have the same formula depending on how you configure it.
Thank you so much for taking all the effort. Really appreciate that. Will give it a try and come back if I get stuck somewhere specifically.
Thanks again!!