Help with RG doing dynamic summing

Hey, been away from bubble for a couple months and i’m a bit rusty. I’m trying to make it so that when a user clicks one of the selections in this RG that it runs a calculation to see how many of the selections in the RG have been selected i.e. when you select one it prints “1”, when you select another it prints “2”. I’m guessing i need to use Orchestra musicians and set states in some way like "when this group set state is “selected” run musicians… or something like that. I just can’t figure it out right now. Any help?

Screen Shot 2022-07-27 at 4.31.25 pm

Update: still have’t figured it out yet but I made it set it to “1” but i can’t figure out how to make it aggregate them i wish it would let me do “+1” something.


Screen Shot 2022-07-27 at 5.21.22 pm

Any help would be much appreciated.

Hi there, @jessefarquhar48… it seems like you’re close to making it work, but if it was me, I wouldn’t use a plugin. A simple custom state (with a State type of number) and a couple of workflow events will do the trick.

I made a quick example. Here is the custom state attached to the repeating group.

Here is the workflow event that runs when a checkbox in one of the repeating group’s rows is checked.

Here is the one and only action in the workflow event.

The workflow event that isn’t shown is exactly the same, except it subtracts 1 when the checkbox isn’t checked.

Finally, a text element with this expression shows the summary of selected habits to total habits.

summary

Hope this helps.

Best…
Mike

2 Likes

Alright we’ve done it mate! You help me get it to work.

Very similar to what you had but i had to put an action step in front of the action step just so i can set the selected group as “yes” or “no” first. You didn’t have to do this because you used check boxes instead of a group.


1 Like

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