# How to get a random text to be pulled out of a data source, then displayed on the screen

**URL:** <https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524>\
**Category:** Questions about Thunkable X\
**Created:** [October 6, 2022, 7:25am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524 "2022-10-06T07:25:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 6, 2022, 7:25am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/1 "2022-10-06T07:25:37Z")

</div>

So In my app I want there to be a feature where every set amount of time a random “challenge” is displayed on the screen. I was wondering how I could do this in a way that I can put in the “challenges” beforehand, I think I could use a data source somehow, but I am not completely sure.

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [October 6, 2022, 7:52am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/2 "2022-10-06T07:52:04Z")

</div>

Yes, add each challenge as a separate row in your data source. Set a variable to the list of values from one column of the data source.

Then, when you want to select a random challenge, get and remove a random item from the list and set a variable to it. Display the variable in a label.

There are some examples here:

> [@Random one data output](https://community.thunkable.com/t/random-one-data-output/1664364):
>
> When the screen is opened among the data from 1 to 100, / it is hoped that ‘one data (1 to 100) will be automatically selected and output randomly’. I’m trying with a spreadsheet, but it doesn’t work. Help me. I’m referring to this, but there’s no " in Local\_DB1 call GetCell ~~"

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 6, 2022, 10:01am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/3 "2022-10-06T10:01:52Z")

</div>

Ok, thanks I will check that out 🙂

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 7, 2022, 7:55am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/4 "2022-10-07T07:55:11Z")

</div>

Before I try what you have said above, does this spreadsheet look like what you had in mind?  
\*The Challenges are just examples, they don’t matter what they are.

 ![Screen Shot 2022-10-07 at 5.53.31 pm](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/1/41c751a144a63f4918bac3c0ab8c68df10f1f6e2.png)

🙂

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 7, 2022, 9:57am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/7 "2022-10-07T09:57:47Z")

</div>

Ok I have looked at the links you have sent me and this is what I have so far, does anything need changing?

 ![Screen Shot 2022-10-07 at 8.17.38 pm](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/2/9270887ce38a98165d0df3a8fba92b16425096d3.png)

Whilst I wait for you to reply I will test it out, Again, Many Thanks Levi

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 7, 2022, 10:25am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/9 "2022-10-07T10:25:51Z")

</div>

So It almost works, When I click the button it changes from “Your Challenge is…” to " null" then I click it again and it shows all of the challenges at once in 1 long list, Here are some photos:

 ![IMG_0451](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/3/130e32da9436c203e366cae9dbd13cc17cfd6e19.png)  
 ![IMG_0450](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/d/ad99f558f40edfad8a9fdb81e9950b9f02cf797a.png)  
 ![IMG_0449](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/2/424906a4ecf9a176eb85affe6e8c1761e7944c1c.png)

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 7, 2022, 10:27am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/10 "2022-10-07T10:27:06Z")

</div>

They go in order from the bottom to the top, Your Challenge is…, null, Do 50 situps ect.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [October 7, 2022, 2:48pm UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/11 "2022-10-07T14:48:01Z")

</div>

The `list of values` block is already a list. When you add a (gear) list block in front of it, you make a list of lists which is not something you generally should do. Please remove the (gear) list block and see if that helps.

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 7, 2022, 10:46pm UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/12 "2022-10-07T22:46:46Z")

</div>

Ok, Thanks I will try that.

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 7, 2022, 10:52pm UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/13 "2022-10-07T22:52:02Z")

</div>

It works, but sometimes because the challenge is random the same challenge theoretically could be done twice in a row, so is there a way to make it so it does not repeat the perivous challenge?

Many Thanks, Levi

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [October 8, 2022, 12:18am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/14 "2022-10-08T00:18:58Z")

</div>

Yes, that’s why I mentioned the `get and remove` block before.

Instead of getting a random item from the list, choose a random number from 1 to the length of the list. Set a variable to that random number value. Then, `get and remove` the item at index [random number variable].

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 8, 2022, 1:31am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/15 "2022-10-08T01:31:04Z")

</div>

Can you show me how to do that in blocks, sorry I can’t find any of the blocks you have stated above, Thanks 🙂

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [October 8, 2022, 3:15am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/16 "2022-10-08T03:15:49Z")

</div>

The `get and remove` block is in this block’s drop-down menu:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/a/eab4e0c94dd43f17df53e009ecda959a9ba88892.png)

But I just realized that that will only work (I think) with a dedicated list. Not with a data source. So you’ll need to do this instead:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/c/2ca41bd81ac00972d234ecbe55362b83a24b7aac.png)

You should be aware that there is a [bug](https://github.com/thunkable/thunkable-issues/issues/1138) that sometimes causes the Get Value block to not work. In that case, you’ll need to do this instead:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/7/07f9eb508ff45cc4f960669b1cafbc713b87baad.png)

It’s probably safer to just go with that to start with.

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 8, 2022, 6:03am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/17 "2022-10-08T06:03:26Z")

</div>

Cool thanks, I will try that out.

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 8, 2022, 6:10am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/18 "2022-10-08T06:10:18Z")

</div>

It works slightly better, about one in 12 times I click the button the challenge result will be the same as before so I would have to press the button twice, but unless there’s an easy way to fix it, then it should not be too much of a problem.

Many Thanks, Levi.

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 8, 2022, 6:11am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/19 "2022-10-08T06:11:16Z")

</div>

I tried both of the screen shot you sent me above the both feel better than what I had, and both of your screenshots felt the same.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [October 8, 2022, 6:35am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/20 "2022-10-08T06:35:37Z")

</div>

If you choose a row number and then delete it, you will never have a repeat.

You can check the error block value to see if there was a problem deleting rows but I doubt that’s the cause.

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 8, 2022, 6:53am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/21 "2022-10-08T06:53:31Z")

</div>

Ok, I will check.

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 8, 2022, 7:08am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/22 "2022-10-08T07:08:45Z")

</div>

What I mean is I would still like them to eventually cycle thought randomly like what I had at the start except not to randomly select the same challenge from the data source twice in a row, because later on I don’t what to be having to type out all the challenges in my spreadsheet after every time someone uses my app.

Many Thanks, Levi.

---

<div class="post-metadata">

**Author:** ![leviocsmithk](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/leviocsmithk/32/136645_2.png) [@leviocsmithk](https://community.thunkable.com/u/leviocsmithk)\
**Post date:** [October 8, 2022, 7:09am UTC](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524/23 "2022-10-08T07:09:27Z")

</div>

If this is too hard to do no worries, I would just like to get everything working perfectly before I move on to other elements of my app. 🙂

[Next page](https://community.thunkable.com/t/how-to-get-a-random-text-to-be-pulled-out-of-a-data-source-then-displayed-on-the-screen/2071524.md?page=2)
