Forum Academy Marketplace Showcase Pricing Features

Mathematical Operation to loop reference a list of things

Hi there,

I have a list of colors (a list of texts, e.g: #ff00ff, #000000… etc), that is 5 entries long.

I then have a repeating group (RG) which can be an infinite length. I want each cell of the RG to sequentially assign its color from the list of colors as follows:

Cell #, List entry #
Cell 1, List entry 2
Cell 2, List entry 3
Cell 3, List entry 4
Cell 4, List entry 5
Cell 5, List entry 1
Cell 6, List entry 2
Cell 7, List entry 3
Cell 8, List entry 4
Cell 9, List entry 5
Cell 10, List entry 1

I am trying to think of a simple mathematical operation that allows me to achieve this but really struggling - does anyone have an idea how to solve this?



For me , the formula would be, for every value of n >=5 :

n - ( (int(n/5) -1 ) * 5 ) -4

Here int = the lowest integer resulting

If it’s not clear, tell me, I inserted this formula into a spreadsheet and it’s working great

1 Like

@bonjourbenny Thanks so much, this looks right to me in excel!!! I just need to have a go getting it working in bubble later today. Given that parenthesis doesn’t seem to be supported I guess the best way is to create a variable for each order of operation to achieve the same effect?

I’ll share my progress a little later in case it benefits anyone else.

Thanks again!

Yes, I guess if parenthesis are not allowed, the only way is to set a custom state for each operation.
But I a newbie here in Bubble so maybe there’s another way ?

So I created 2 hidden variables so the order of operations were respected.

I then referenced the last variable in the cell of the Repeating Group.

I confirmed it is now, working thanks @bonjourbenny for your help!

Screenshots below:
Screenshot 2021-10-05 at 17.39.44
Screenshot 2021-10-05 at 17.39.55
Screenshot 2021-10-05 at 17.40.05

Great ! Glad to know it’s working !

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