Sub-operation between field or repeating group

Hi,

I have a repeating group of items to purchase.
Each item has, among other fields: price, tax%, quantity.
Because I am using auto binding I don’t want to create field for each item that calculate Tot Netto and Tot Brutto for each Item (I would not know how to auto-bind them!).
Therefore I want to have a Text fiedl in the bottom that Calculates the totals of all the item in my list:
TOT NETTO: for each item. multiply price/unit and quantity and summ all of them
TOT BRUTTO: … add taxes.

Any idea how to do it?

Thanks,

Sergio

Hey Jarrad, I saw your example in another post.
This is a kind of not general solution, but I have to put a limit to the number of items in the list (e.g. 20) and there sum 20 times the formula.
I was hoping that meanwhile bubble had developed a more general approach for very long lists…
but for now it will do…

Thanks

Sergio

No worries, maybe this might be worth looking at if you haven’t already,

Keep in mind a lot of things in bubble will still calculate even when hidden so maybe this table hidden could be a way out. Also have a look at the math.js and the toolbox plugins as math functions or JavaScript variables might help to knock down the code. Cheers

So,

I found the function Calculate Formula/Sumproduct.
It works very well to calculate the Total Netto: Price * Quantity, but it is limited to ONLY two items!

But for Tot Brutto I need to multiply also the Taxes for each item.
@emmanuel, can be extended at least to 3 items!!! That would do the trick in a scalable and elegant way…

A total field for each record is the currently popular way to do this.

If you want to try the Toolbox’s “List Item Expression”:

field("Quantity") * field("Price") * field("Tax%") / 100

This will give a list of totals which you can then :sum.

2 Likes

Hi,

this seems exactly what I need! but I cannot make it work.
The result of the ListItem Expression is a list of number right?

Therefore I create a text that visualize the sum

unfortunately I still get 0! :frowning:

It seems there is something in the way I call the field("") or value()… is there an example, a tutorial that can help me our? What I am suppose to use to call the data? The name used in the database editor? do I have to use underscore instead of spaces?

Please advise, thanks a lot!

I solved.

There is an issue in the name of the field in the database. Is that a bug?

I messed in the past with name of the fields, and delete some, but the system keep having them hidden.
If I copy and Paste a Data type, they all reapper in the copy and I could see there were two identical called “Price”.
I just renamed the one I was using as PriceNetto, and now everything works piece of cake.

Thanks!

Sergio

1 Like

Yes, an example app, the data is a bit messed up from being played with: app editor

You can display the list directly in a text element, before doing a sum on it.

Interesting, perhaps the method it uses is vulnerable to field name changing or spaces. Thanks for highlighting that.

Well done getting it to work!

Misha

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