# Sub-operation between field or repeating group

**URL:** <https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564>\
**Category:** Need help\
**Created:** [May 18, 2017, 4:35pm UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564 "2017-05-18T16:35:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergio.rufini](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sergio.rufini/32/6485_2.png) [@sergio.rufini](https://forum.bubble.io/u/sergio.rufini)\
**Post date:** [May 18, 2017, 4:35pm UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/1 "2017-05-18T16:35:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [May 18, 2017, 4:57pm UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/2 "2017-05-18T16:57:12Z")

</div>

> [@Do subtotal of calculation of 2 fields in repeating group](http://forum.bubble.io/t/do-subtotal-of-calculation-of-2-fields-in-repeating-group/13525/19):
>
> This is easy dude, I’m on my phone so I will show you the rule… since your only going to have 10 or so cells even if it’s 20 that’s ok too… just keep adding #3 then #4 and so on… the number 1 relates to the first cell and so on. [image]

---

<div class="post-metadata">

**Author:** ![sergio.rufini](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sergio.rufini/32/6485_2.png) [@sergio.rufini](https://forum.bubble.io/u/sergio.rufini)\
**Post date:** [May 19, 2017, 7:20am UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/3 "2017-05-19T07:20:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [May 19, 2017, 7:45am UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/4 "2017-05-19T07:45:19Z")

</div>

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

> [@\[New Feature\] Excel-like table](http://forum.bubble.io/t/new-feature-excel-like-table/2125):
>
> Hello, We’ve just added an Excel-like element! That will let you display list of things in a spreadsheet. Look for the plugin “Excel-like HandsonTable”. It works very much like a repeating group. You pick a data type, then define the data source. The difference is that you need to select which columns you want to show/hide. And you’re all set. At this stage, the table will only show “simple” fields (whose type isn’t another custom type), and the table is read-only. You can refer to the thing …

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

---

<div class="post-metadata">

**Author:** ![sergio.rufini](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sergio.rufini/32/6485_2.png) [@sergio.rufini](https://forum.bubble.io/u/sergio.rufini)\
**Post date:** [May 19, 2017, 7:51am UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/5 "2017-05-19T07:51:31Z")

</div>

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!

![](https://us1.discourse-cdn.com/bubble/original/2X/b/bb9e5dbd6aa136e68109c37e34990eac8f01dbac.png)

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…

---

<div class="post-metadata">

**Author:** ![mishav](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mishav/32/6420_2.png) [@mishav](https://forum.bubble.io/u/mishav)\
**Post date:** [May 19, 2017, 3:53pm UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/6 "2017-05-19T15:53:27Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![sergio.rufini](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sergio.rufini/32/6485_2.png) [@sergio.rufini](https://forum.bubble.io/u/sergio.rufini)\
**Post date:** [May 23, 2017, 11:36am UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/7 "2017-05-23T11:36:27Z")

</div>

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?  
 ![](https://us1.discourse-cdn.com/bubble/original/2X/d/de957cced41824578e9d7ef7bd402a37f5d49e50.png)  
Therefore I create a text that visualize the sum  
 ![](https://us1.discourse-cdn.com/bubble/original/2X/7/74409e7bf609bb5018242e0d8be0fc303d5ef1ae.png)

unfortunately I still get 0! ☹

---

<div class="post-metadata">

**Author:** ![sergio.rufini](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sergio.rufini/32/6485_2.png) [@sergio.rufini](https://forum.bubble.io/u/sergio.rufini)\
**Post date:** [May 23, 2017, 8:50pm UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/8 "2017-05-23T20:50:54Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![sergio.rufini](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sergio.rufini/32/6485_2.png) [@sergio.rufini](https://forum.bubble.io/u/sergio.rufini)\
**Post date:** [May 23, 2017, 9:28pm UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/9 "2017-05-23T21:28:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mishav](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mishav/32/6420_2.png) [@mishav](https://forum.bubble.io/u/mishav)\
**Post date:** [May 24, 2017, 12:16pm UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/10 "2017-05-24T12:16:26Z")

</div>

> [@sergio.rufini](#):
>
> is there an example, a tutorial that can help me our

Yes, an example app, the data is a bit messed up from being played with: [app editor](https://bubble.io/page?type=page&name=list-item-expression&id=toolbox-example&tab=tabs-1)

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

> [@sergio.rufini](#):
>
> I messed in the past with name of the fields,

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

> [@sergio.rufini](#):
>
> now everything works

Well done getting it to work!

Misha

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [July 27, 2017, 4:35pm UTC](https://forum.bubble.io/t/sub-operation-between-field-or-repeating-group/13564/11 "2017-07-27T16:35:45Z")

</div>

Closed on July 27, 2017, 4:35pm UTC

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