How to get different random values on button click

Hi there,

We have a button set up, that, upon clicking it, changes the values for 8 rows randomly, by pulling in data from another table.

The code that randomly selects the first value is the following:

Filter([All Shopify products],Store="the-design-part.myshopify.com").Nth(RoundUp(Random()*Filter([All Shopify products],Store="the-design-part.myshopify.com").Count(),0))

This will pull in a random value, however, the value will be the same for all 8 rows, so we fixed it by adding a different number for each row that is being updated. Ex:

Filter([All Shopify products],Store=“the-design-part.myshopify.com”).Nth((RoundUp(Random()*Filter([All Shopify products],Store=“the-design-part.myshopify.com”).Count(),0))+24)

(The only change here is +24)

However the issue with this, is that sometimes the value that is returned be outside of the total rows that are present in that table, and thus will return an error, saying that this row does not exist.

-How can we ensure that upon clicking the “randomize” button, all the 8 values are different, and are actually within the total rows of the table?

I’ve made a recording to show the issue here: https://www.loom.com/share/a3c3e9c9f74440f5a16f3cffc0751496

Dear @Max_Pauwels,

I understand that the data in your original doc might contain sensitive data, but it’s a rather big catch to find a solution on something that is well documented, but not so easy (time consuming) to reproduce and not being sure if this is your actual problem.

I recommend to copy your original doc and simplify it by keeping only the button and it’s related tables to generate the random values, so there is a clear picture from what you have and where you want to go.

After a solution is found, and you learn the “how to” it should be rather simple to implement this in your original doc. Many doc builders, incl. me, use this method to test solutions without violating the original doc.