How to generate random subset from the customlist

labels: [“Red”, “Blue”, “Yellow”, “Green”, “Purple”, “Orange”]

custom list can generate only one value from the custom list

but what I want is a subset of the custom list as an array for the labels col

When generating JSON data, you can simple add “[n]” to the name of any field to generate an array of values. For example, “labels[3]” will generate 3 randomly selected values in an array.

See http://mockaroo.com/help/json

If you’re generating CSV, you need to use a Formula field, like:

['red', 'green', 'blue'].sample(2).join(', ')
1 Like

Is it possible to randomize the number of items? For example:

labels[n] where n is a range like labels[1-5]

OR

[‘red’, ‘green’, ‘blue’].sample(n).join(’, ') where n is a randomly generated number from 1-5

I have a list of countries and need to 1 to n country names appear in each cell when I export the data from Mockaroo to Excel.

You can use the random(n,m) function in the sample function to create a random amount of items:

['red', 'green', 'blue', 'yellow', 'brown'].sample(random(1,5)).join(', ')