How to Sum up Input fields values in a Repeating Group?

Advanced Bubblers :slight_smile:

Quick Question, is it possible to sum Input fields to give them “dynamic” valid min and max limits.

So for better understanding, I have a Repeating group of 3 “Products” and the customer can choose 5 Products out of this 3 Product lines. how can I adjust the input field in a way that he can add the Sum of 5?
fex:
Product 1 = input 1 (so for product 2 & 3 the sum will be 4)
when the next choice is Product 2 = input 3 ( so for product 3 the sum will be 1)
How can I validate that ??

Thanks you for your help in advance.

Hopefully I’m understanding you correctly. I put together a demo here, check it out – coaching-sandbox | Bubble Editor

In the “max” fields for all 3 inputs, I used the expression “5 minus the difference between the other 2 inputs”

Since I want to start with “5,” you’ll see I put that in an arbitrary text converted to number.

I also added conditions to all three inputs so if they’re invalid, it changes color.

Is this what you were looking for?

Cheers,
Gaby
Coaching No Code Apps

1 Like

will this work for a repeating group, if the total is outside of the repeating group?

HI Gaby, (btw big fan of your channe :slight_smile: )

The problem is the other way round and input 1,2,3 are within a repeating group.
So if input 1 would be 3 as a quantity the remaining quantity would be 2.
So the customer would have the choice to eider select 1 (Quantity) and 1 (Quantity) in the remaining input fields, or 2 (Quantity) in one of the remaining input fields and than 0 (Quantity) would be in the remaining in put field.

best regards
Vik

HI Gaby, (btw big fan of your channe :slight_smile: )

The problem is the other way round and input 1,2,3 are within a repeating group.
So if input 1 would be 3 as a quantity the remaining quantity would be 2.
So the customer would have the choice to eider select 1 (Quantity) and 1 (Quantity) in the remaining input fields, or 2 (Quantity) in one of the remaining input fields and than 0 (Quantity) would be in the remaining in put field.

best regards
Vik

1 Like

OK – this was… fun.

I added a repeating group to the demo page (you can ignore the stuff outside the repeating group). Go ahead and make different selections with the dropdowns to see the behavior.

The RG has 3 products, so 3 rows. Each row has a dropdown with options from 0-5. The data source of the dropdown is a “list of numbers” from the toolbox plugin.

I’m also using the RG Extractor plugin to extract the dropdown values from each cell. You’ll see a “Transmit Data” element in the cell, and a “Receive Data” element outside the RG.

The real logic is in the dropdown’s default data source and the condition to change the data source slightly when there’s already a value in the dropdown.

So the filter is comparing the sum of the already selected quantities + each number in the “list of numbers” and if that result is less than or equal to 5, it stays in the list.

The condition has to subtract the currently selected value to achieve the same comparison.

Look through the expressions and let me know if I can help explain any part of it further.

2 Likes

Hi Gaby,

this solves my problem 100%, well done :wink: , thank you Gaby great job.
I learned a hole new thing.
RG
Vik

2 Likes

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