How to make multiple selections from a list

Is it possible to put some sentences in text in a list and then randomly select several of them? If I only want to select one, I can do it with random-text, but if there is a way to select several, please let me know.

Hey again @Naritatsu_Saito

I can think of a way to do this that involves an ordered list. Note that, because this uses formulas, it requires a Pro, Business, or Enterprise plan with Text Blaze.

You could start by creating an ordered list of your sentences: Text Blaze | Formula Reference

Then, you could use random number to select two random numbers, assigning those selections to variables: Text Blaze | Randomize

Finally, use your variables to select your sentences from your ordered list.

This may result in getting the same sentence multiple times since the selections are made at random independent of each other. I can think some more about how you might re-draw a random number if the same one is selected twice.

Here's a sample snippet I made that follows that advice in this comment. This won't work in the community because it uses the {random-number} command, but should work in your Text Blaze account if you have Randomize enabled (see link above for details)

{sentences=["This is a sentence", "This is also a sentence", "I am another sentence", "This is the fourth sentence in my list", "I am the fifth sentence"]; trim=yes}
{sentence1={random-number: min=1; max=5; rounded=yes}; trim=yes}
{sentence2={random-number: min=1; max=5; rounded=yes}; trim=yes}
{=sentences[sentence1]; trim=left}
{=sentences[sentence2]}

Thanks for the reply, the free community is helpful, thanks to Text Blaze and Andrew_Hall.

I'd like to select from the list without duplicates, but that seems difficult with the method you've given me, what if I combine it with Data Blaze? I'll give it some thought.

Hi @Naritatsu_Saito , if you are concerned about duplicates, you can 1. first sort the list in a random order (see How To Randomize List Order? - #4 by scott) and then 2. pick the first two items from it, like this:

{sentences=["This is a sentence", "This is also a sentence", "I am another sentence", "This is the fourth sentence in my list", "I am the fifth sentence"]; trim=yes}

{randomizelist=(list) -> map(sort(map(list, x -> ["id":random(), "value":x]), (a,b) -> a.id - b.id), x -> x.value); trim=yes}

{random_sentences=randomizelist(sentences); trim=yes}

{sentence1=random_sentences[1]; trim=yes}
{sentence2=random_sentences[2]; trim=yes}

First sentence: {=sentence1}
Second sentence: {=sentence2}

2 Likes

Gaurang, Thanks, that's what I want. Bingo!!

1 Like