Pick a random line in a table

Hi all
I have a glide table that contains the projects of students. One field contains the url leading to a video the students can upload if they want. I now want to highlight the projects that have a video uploaded by showing these videos. But I only want to show one video but a new one every day.

So I need a routine that picks the lines that contain a video only. and then I need another routine that picks a different line every day to insert this url for the video element in the glideapp. I have no idea if this even works - any suggestions appreciated.

Try this:

  • Create a Query column that targets the Projects table, and filter it where the Video column is not empty.
  • Add a Single Value → Random column to select a Video via the Query column.
2 Likes

That sounds great. Does the random pick ever change? Or is there a way to make it pick another item in the query column after some time?

Here’s another idea:

Create a list of videos with a collection component, limit the number of items in the collection to one (now you are only displaying one single video), and in the options set the sort to random. This will display a new video every time the screen loads.

EDIT: You can also add a button on the screen with a shuffle action to control when the random item shuffles.

3 Likes

Great Idea. Thank you so much.
I tried both and they both work fine.

The first one allows me to see the video directly.
With the second proposal I can only show a picture but not the video itself

1 Like

Or maybe you can have a custom collection and use the random method Nathanael suggested above.

1 Like