RandomInteger formula returning strange result

Hello All,

I am hoping someone might be able to explain why this formula -

image

… only returns multiples of 3. (Note, the image there is just as I have written the formula on the canvas, it’s not part of a larger formula.)

It’s like it is getting a single RandomInteger and then multiplying. What is doubly mystifying to me is that I have used this exact formula in another doc and it works exactly as I expect, I get a value between 3 and 18.

But I wonder if something might be going on in the background of the coda servers because yesterday a formula I had written with a simple If(date1 < date2, … simply would not work correctly (that is, it returned true even when date1 was >= date2) for several hours while I tore my hair out, and then all of a sudden it started working as expected (and no, I hadn’t changed anything, I was simply debugging, for a looooong time).

Any ideas would be much appreciated.

Thanks,

Rohan

Not sure if I’ll explain this well, but within the same context, multiple randomized results will return the same randomized result.

For example, this will return two of the same letters even though it’s random.

Concatenate(
  RandomItem(List('a', 'b', 'c')),
  RandomItem(List('a', 'b', 'c'))
)

Basically you’ll need to use two seperate canvas formulas and concatenate them together in one formula to make it work!

Hi Micah,

Thanks so much for your reply.

I was thinking it might be that, but if that is the case, why would this formula, in another doc, produce a random result between 3 and 18?

2023-12-09_10-25-05

Surely these are also in the same context? :thinking: … This is why I am confused.

It’s still going to give somewhat a random result, but like you said, it’s getting one random number, then multiplying it by 3 since you have 3 different randomIntegers().

Every result you get from that other doc should be able to be divided by 3 which will give the single number all 3 randomIntegers() got.