# Can a data be "dynamic"?

I have a data type called Receipt and a field Grand Total. Grand Total is the total of the items listed in the Receipt.

The problem comes when you change the price of an item. The Grand Total should be the sum of all prices of items listed in the receipt. It calculates one time and stores the data, but when changed, it doesn’t update dynamically, unlike for example, in excel, where it automatically updates the grand total if a cell is changed.

Is it possible to do this in bubble or a workflow must be done to recalculate the grand total everytime the item is changed?

Yes, use this workflow action, “make changes to a list of things”:

But this is exactly what I’m trying to avoid, creating a workflow to recalculate the grand total.

For example, when saving a new thing, it will be Grand Total = list of item’s subtotal:sum

Now this is correct, but the problem comes when an item in those list of items’ subtotal changed, the Grand Total still remains the same as when you first stored that data.
You have to manually create a new action to recalculate the grand total again everytime you modify an Item.

I’m asking if it’s possible to make a data dynamic similar to how it works in excel formulas. Where if you define one cell = sum of a range of cells, if you change the value in one cell, that sum automatically gets updated.

I hope this makes it clear.

I still think the “changes to a list of things” is what you are looking for.

Here is my understanding of your situation:
You have many receipt records in your receipts data type. The Grand Total contains the sum of all items’ sub-totals, where sub-total = units x price.
You then have a need to update the price, and you want all grand totals to update accordingly.

If this is correct, then you would do a search for all receipts containing this item and calculate the new sub-totals first, and then the GT.

You can display the grand total dynamically with a text field. Set it to ‘this receipts items total: sum’. That will automatically reflect changes to an items price.

If you want to store the grand total as a number on the receipt thing you will have to create a workflow that updates that total when a line item is changed.

This is a great scenario for the new backend data triggers.

2 Likes

It should also be noted: In the same way that you can simply display such a computed value, you always have access to that value, so there’s no need – in general – to “store it in a field”.

The “Grand Total” is a derived value that’s just the sum of the items.

HOWEVER, there are cases where we might want to permanently store such a value and something called a Receipt would be one of these.

The name Receipt implies that the receipt object is a record of what we charged somebody for some purchase. A Receipt should not change if the price of a line item changes in the future.

@abhi may be playing fast and loose with their naming conventions here, but if they are truly trying to model a Receipt (and not, say, an “Order” or a “Shopping Cart” that represents something somebody might purchase in the future, but has not yet committed to) then it should not be possible for the values in a Receipt to change.

Hi @abhi ,
Were you able to solve your question?
If so, would you share it here?
I have a similar scenario I am trying to solve.