# Sum of inputs from a repeating group

**URL:** <https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832>\
**Category:** Need help\
**Created:** [May 5, 2021, 3:44pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832 "2021-05-05T15:44:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nig3b](https://avatars.discourse-cdn.com/v4/letter/n/5f8ce5/32.png) [@nig3b](https://forum.bubble.io/u/nig3b)\
**Post date:** [May 5, 2021, 3:44pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/1 "2021-05-05T15:44:29Z")

</div>

Hi bubblers!

I have looked for hours to find a solution but it doesn’t seem there’s an easy one in the forum except using the bdk plugin.

I have a repeating group in which I have inputs. I do calculations in these inputs. I want to have the sum of all these inputs that are in the repeating group.

It seems crazy to me that there’s no build-in solution, to sum up, all inputs from a repeating group.

Does anyone have an easy solution to implement?

Thanks!

---

<div class="post-metadata">

**Author:** ![steve18](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/steve18/32/94063_2.png) [@steve18](https://forum.bubble.io/u/steve18)\
**Post date:** [May 5, 2021, 4:01pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/2 "2021-05-05T16:01:00Z")

</div>

There is I think. If you chuck a custom state on the page or some other element (I always use the page for variables), you can add to the custom state as people change the values in the input RG.

I had a bit of a play here:

> **[Bubble - Visual Programming](https://fun-sandbox.bubbleapps.io/version-test/sum_rg?debug_mode=true)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

Dev here:

> **[Bubble Editor - Fun-sandbox](https://bubble.io/page?type=page&name=sum_rg&id=fun-sandbox&tab=tabs-1)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

Does that help?

---

<div class="post-metadata">

**Author:** ![robhblake](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robhblake/32/60625_2.png) [@robhblake](https://forum.bubble.io/u/robhblake)\
**Post date:** [May 5, 2021, 4:46pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/3 "2021-05-05T16:46:17Z")

</div>

It works as long as the user doesn’t go back and change their input 😉

---

<div class="post-metadata">

**Author:** ![nig3b](https://avatars.discourse-cdn.com/v4/letter/n/5f8ce5/32.png) [@nig3b](https://forum.bubble.io/u/nig3b)\
**Post date:** [May 5, 2021, 4:56pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/4 "2021-05-05T16:56:15Z")

</div>

Thanks. I have been able to replicate what you did. Now I’m going to try to understand it!!

---

<div class="post-metadata">

**Author:** ![steve18](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/steve18/32/94063_2.png) [@steve18](https://forum.bubble.io/u/steve18)\
**Post date:** [May 5, 2021, 5:10pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/5 "2021-05-05T17:10:53Z")

</div>

…true

---

<div class="post-metadata">

**Author:** ![steve18](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/steve18/32/94063_2.png) [@steve18](https://forum.bubble.io/u/steve18)\
**Post date:** [May 5, 2021, 5:11pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/6 "2021-05-05T17:11:33Z")

</div>

Can I help? What specifically are you struggling with?

---

<div class="post-metadata">

**Author:** ![SerPounce](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/serpounce/32/62068_2.png) [@SerPounce](https://forum.bubble.io/u/SerPounce)\
**Post date:** [May 5, 2021, 5:39pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/7 "2021-05-05T17:39:56Z")

</div>

Workaround solution here:

> [@Calculating grand totals in repeating group](http://forum.bubble.io/t/calculating-grand-totals-in-repeating-group/100804/7):
>
> What is the criteria for how businesses get included in the RG? i.e. what is the data source for the RG? I might have an idea for a hack workaround, but need to understand better how the RG gets constructed.

---

<div class="post-metadata">

**Author:** ![robhblake](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robhblake/32/60625_2.png) [@robhblake](https://forum.bubble.io/u/robhblake)\
**Post date:** [May 5, 2021, 5:56pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/8 "2021-05-05T17:56:00Z")

</div>

Funny, I was trying to solve this last weekend and had the same solution as @steve18 . Looking at it again with a fresh head we were actually quite close. Only thing missing was to track the previous value and in that way increase the grand total by the difference (rather than the total for that cell).

[Here’s my solution](https://rhbsandbox.bubbleapps.io/version-test/shopping_cart).

(There are two workflows but they are identical - just telling it to update the total when either the price or the quantity is updated)

---

<div class="post-metadata">

**Author:** ![nig3b](https://avatars.discourse-cdn.com/v4/letter/n/5f8ce5/32.png) [@nig3b](https://forum.bubble.io/u/nig3b)\
**Post date:** [May 5, 2021, 6:36pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/9 "2021-05-05T18:36:55Z")

</div>

I don’t know anything (yet!) on custom state. So I think I understand but I need to try things before I completely get it.  
The inputs are calculated in RG with lots of data 😉

---

<div class="post-metadata">

**Author:** ![nig3b](https://avatars.discourse-cdn.com/v4/letter/n/5f8ce5/32.png) [@nig3b](https://forum.bubble.io/u/nig3b)\
**Post date:** [May 5, 2021, 6:39pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/10 "2021-05-05T18:39:39Z")

</div>

Thank you. I see that you are also using custom state. Definitely the way to go then! I’m going to learn how they work

---

<div class="post-metadata">

**Author:** ![steve18](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/steve18/32/94063_2.png) [@steve18](https://forum.bubble.io/u/steve18)\
**Post date:** [May 5, 2021, 6:51pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/11 "2021-05-05T18:51:02Z")

</div>

British Bob Ross has your back:

[![](https://img.youtube.com/vi/9DgHUmicjlM/maxresdefault.jpg "Custom States | Bubble.io Tutorial") ](https://www.youtube.com/watch?v=9DgHUmicjlM)

---

<div class="post-metadata">

**Author:** ![equibodyapp](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/equibodyapp/32/159574_2.png) [@equibodyapp](https://forum.bubble.io/u/equibodyapp)\
**Post date:** [May 5, 2021, 10:05pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/12 "2021-05-05T22:05:47Z")

</div>

You can’t just go ‘repeating group’s list of things’s field:sum’? Autobind that field to the input element and it will automatically update when the user changes the value in the element.

Or using the Expressions element with the Toolbox plugin and some custom states

> **[Bubble Editor - toolbox-example](https://bubble.io/page?type=page&name=rg-sum-inputs&id=toolbox-example&tab=tabs-1)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

> **[Bubble - Visual Programming](https://toolbox-example.bubbleapps.io/version-test/rg-sum-inputs?debug_mode=true)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

I use a combination of both in my invoicing functionality.

---

<div class="post-metadata">

**Author:** ![robhblake](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/robhblake/32/60625_2.png) [@robhblake](https://forum.bubble.io/u/robhblake)\
**Post date:** [May 6, 2021, 1:10am UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/13 "2021-05-06T01:10:30Z")

</div>

Yep that’s fine if the data you’re summing up already lives in the database. That isn’t the case here. Doing this on the client side with custom states is quicker too.

---

<div class="post-metadata">

**Author:** ![equibodyapp](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/equibodyapp/32/159574_2.png) [@equibodyapp](https://forum.bubble.io/u/equibodyapp)\
**Post date:** [May 6, 2021, 1:21am UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/14 "2021-05-06T01:21:22Z")

</div>

That’s what the second option I posted is for…

---

<div class="post-metadata">

**Author:** ![nig3b](https://avatars.discourse-cdn.com/v4/letter/n/5f8ce5/32.png) [@nig3b](https://forum.bubble.io/u/nig3b)\
**Post date:** [May 6, 2021, 12:11pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/15 "2021-05-06T12:11:44Z")

</div>

I have a hard time understanding how to do it as I have no input change.

You can see the example here:

> **[Bubble Editor - Testnig3b](https://bubble.io/page?type=page&name=custom_states&id=testnig3b&tab=tabs-1)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

---

<div class="post-metadata">

**Author:** ![equibodyapp](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/equibodyapp/32/159574_2.png) [@equibodyapp](https://forum.bubble.io/u/equibodyapp)\
**Post date:** [May 7, 2021, 2:21am UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/16 "2021-05-07T02:21:46Z")

</div>

So the user doesn’t need to input anything in the RG? Why are they input elements and not text elements if that is the case?

You might need the toolbox plugin and the expressions element or the instant calculator plugin to make life easier for yourself.

Or you could create new field in your data type for number of months and total plan amount, then trigger a backend WF on page load or group show to calculate new figures for each. Then you could use the repeating group’s list of items’ total plan amount:sum

---

<div class="post-metadata">

**Author:** ![nig3b](https://avatars.discourse-cdn.com/v4/letter/n/5f8ce5/32.png) [@nig3b](https://forum.bubble.io/u/nig3b)\
**Post date:** [May 7, 2021, 8:28am UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/17 "2021-05-07T08:28:33Z")

</div>

> So the user doesn’t need to input anything in the RG?  
> → That’s correct

> You might need the toolbox plugin and the expressions element or the instant calculator plugin to make life easier for yourself.  
> → I have installed the instant calculator plugin but I don’t see how it should be helping

> Why are they input elements and not text elements if that is the case?  
> → So I can do the multiplication between the number of months and the total per month

> Or you could create new field in your data type for number of months and total plan amount, then trigger a backend WF on page load or group show to calculate new figures for each. Then you could use the repeating group’s list of items’ total plan amount:sum  
> → So I should create new data in my DB? Just to calculate the sum?  
> These calculations would be triggered when the page is loaded inside a repeating group? How to then automatically update the DB with these? It’s the same problem I’m facing I feel ;(

I tried to create a scheduled API WF but I can’t figure how to do it

---

<div class="post-metadata">

**Author:** ![nig3b](https://avatars.discourse-cdn.com/v4/letter/n/5f8ce5/32.png) [@nig3b](https://forum.bubble.io/u/nig3b)\
**Post date:** [May 7, 2021, 9:04pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/18 "2021-05-07T21:04:15Z")

</div>

If anyone has a solution, the issue is there:

> **[Bubble Editor - Testnig3b](https://bubble.io/page?type=page&name=custom_states&id=testnig3b&tab=tabs-1)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

I have tried with a Scheduled API Workflow and the Custom States method but I can’t sum an input from a RG nor I can update the DB with the individual Sums.

I just want the sum of inputs with the yellow background to show in the red background input !  
Or to update the DB with all the yellow background when the page in loaded

---

<div class="post-metadata">

**Author:** ![equibodyapp](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/equibodyapp/32/159574_2.png) [@equibodyapp](https://forum.bubble.io/u/equibodyapp)\
**Post date:** [May 7, 2021, 10:10pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/19 "2021-05-07T22:10:38Z")

</div>

You have to tick this when it’s a list 🙂

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/7/7/77ee95e7327456a84952b64e58de8c86ffb7b083.png)

You just got to play around with the backend workflow to convert the date to numbers but I’ve put an example in there for you.

---

<div class="post-metadata">

**Author:** ![nig3b](https://avatars.discourse-cdn.com/v4/letter/n/5f8ce5/32.png) [@nig3b](https://forum.bubble.io/u/nig3b)\
**Post date:** [May 7, 2021, 10:29pm UTC](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832/20 "2021-05-07T22:29:31Z")

</div>

Thanks. In the backend there’s no option to select the data in the input “TotalEachPlan”. I cannot get the data to be updated ☹

 ![Screen Shot 2021-05-08 at 12.28.09 am](https://us1.discourse-cdn.com/bubble/original/3X/e/d/ed22f5bfd97678bf996f015837f51ba8aaa7e961.png)

[Next page](https://forum.bubble.io/t/sum-of-inputs-from-a-repeating-group/149832.md?page=2)
