Displaying 3 Random Items from a Data Source in Thunkable

Hi, i am new to thunkable and it’s logic area and i need your help. i have a data viewer list that is connected to my spreadsheet data source.
There are 27 items in my data source but i only want 3 out of the 27 items to show. And each time the user refreshes the screen, another 3 random items will load. how do i do this?

and this is what my data source looks like below
image

Thank you in advance

  1. AT THE BEGINNING, use this to build a random list of 1-27
    image

  2. feed the result into the list part of this block:
    image

  3. WHEN BUTTON IS CLICKED, get item #1 using this block - the number you get is the index for obtaining the corresponding row contents from your data source
    image
    (replace the list part with your new list of course.

  4. remove the same number from the list using this. (only the temporary list of random number is updated, not the data osurce)

image
5. repeat 3 and 4 two more times
6. if the length of remaining list is < 3, then do step 1 and 2 again.

2 Likes

Thanks for getting back to me so quickly. So i tried your method and this is what i came up with:

But it’s not working, probably because i did something wrong but i can’t figure out what it is. When i preview the home screen, the data viewer list is still showing all 27 items, seeing the way it scrolls down more.
image

Also, is there a way to generate the random items without them clicking a button

your app was designed with a home screen that’s connected to to a full table of food products (27 items) always. whenever screen resets.

if you want the behavior to change - show only 3 random items - at screen open, then you need to define a new list (same structure at your original table) and change the dataviewer to be associated with that new list.

how to populate this new table? at screen open, shuffle the numbers from 1 to 27.
loop over the shuffled list for j=1 to 3. for each index(j), obtain the corresponding row of your original table and populate the jth row of your new table.

after the loop, the selected list should show.