Conditional count depending on embedded RG in previous RG cells

Hi all. I have a complicated issue that I cannot resolve and I could not find anything similar to in the forum.

Background:

I have some user data. Lets say it looks like this:

DATASET 1

NAME                 GROUP
Data 1.1                none
Data 2.1                A
Data 3.1                A
Data 4.1                none
Data 5.1                none

DATASET 2

NAME                 GROUP
Data 1.2                A
Data 2.2                A
Data 3.2                none
Data 4.2                B
Data 5.2                B

Items in a group are displayed together. Because of this I have a nested repeating group.

  • The outer RG group lists the DATASETs.
  • The inner RG lists the Data.
  • A Group can have 2 or more items and it is unknown in advance how many.

The user is able to select how many items from each DATASET to display.

For example, if the user wants to display 1 item, the result is:

DATASET 1
Data 1.1

DATASET 2
Data 1.2
Data 2.2

If the user wants to display 3 items, the result is:

DATASET 1
Data 1.1
Data 2.1
Data 3.1
Data 4.1

DATASET 2
Data 1.2
Data 2.2
Data 3.2
Data 4.2
Data 5.2

I can make this work if I hard code a condition for each specific variation. But that’s not a very good way to do this!

PROBLEM:

My problem is that after an inner RG contains a group, in the next cell of the outer RG I need to know which item in my list to start from. In my second example, the outer RG has these data counts for it’s inner RG:

Outer RG   Inner RG Count
Cell 1         2
Cell 2         1
Cell 3         2

So how can I know in cell 2 that I need to begin with list item #3?
And in cell 3 I need to begin with list item #4?

I need a cumulative count of the number of list items for each of the previously nested RGs. In traditional programming this would not be too hard, but I cannot see how to get there in Bubble.

I’ve thought about using Run Javascript from the Toolbox, but that would require a workflow. I’m okay with that if it would work but I still don’t know how I can get those cumulative counts to a javascript that would be the same for every cell.

If you need any further clarification please let me know. I’m open to any ideas.

I did previously ask about this issue and received a decent reply from @romanmg but unfortunately that solution was not quite right. Gaby took my example literally and hard coded the option of viewing 5 by creating 5 RGs, but this is actually dynamic. I can’t know in advance how many items will be in the list or how many the user needs to show. This is why I’m embedding a RG in another RG. I just can’t figure out how to know where to pick up the list position after a group has been displayed.

TIA

Sounds like you could use this plugin to output the number of items in each inner RG as a list, then get the sum of all the values until current cell’s index.

1 Like

Thanks. That plugin looks interesting. But all of the examples show the use of the RG data from outside of the RGs. I don’t see examples that work from within a cell of the repeating group.

In other words, can it get the total number of rows for all of the inner repeating groups for each outer RG cell above the current cell.

That would tell me which list item to start with for that outer RG cell. Do you know if this plugin can do that? There isn’t a free trial so I wanted to ask before trying it. I cannot make much sense of the example editor provided.

The plugin will output all of the values from each cell as a list

So from your example, the plugin output would be a list of numbers (2, 1, 2)

Then to get the total number of rows for the inner RGs above the current cell, your expression would look something like

List of numbers: items until #Current Cell’s Index:sum

You can subscribe to the monthly plugin plan, and play around with it, and cancel it if needed. This will only incur a charge of a few cents depending on how much time you spent with it installed.

You can group them by GROUP. Then use the group as the 1st RG. Then filter the all list of data inside each group to show the items for each group.

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