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?
AT THE BEGINNING, use this to build a random list of 1-27
feed the result into the list part of this block:
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
(replace the list part with your new list of course.
remove the same number from the list using this. (only the temporary list of random number is updated, not the data osurce)
5. repeat 3 and 4 two more times
6. if the length of remaining list is < 3, then do step 1 and 2 again.
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.
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.