Sum of inputs from a repeating group

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!

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:

Dev here:

Does that help?

1 Like

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

1 Like

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

…true

Can I help? What specifically are you struggling with?

Workaround solution here:

1 Like

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.

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

2 Likes

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 :wink:

1 Like

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

1 Like

British Bob Ross has your back:

2 Likes

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

I use a combination of both in my invoicing functionality.

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.

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

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

You can see the example here:

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

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

If anyone has a solution, the issue is there:

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

You have to tick this when it’s a list :slight_smile:

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.

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