I have a Glide table that contains a column with a list of quotes (one per row), and I’d like to select one at random to display on the home screen each time it’s viewed.
What’s the best way to do this?
(I feel a bit embarrassed that I can’t figure this out, but having a mental block… )
Hi @ThinhDinh sorry to revive this so many years later, but is there a way in which I can filter out which value is ‘randomly’ selected? I want to similarly pull a random text except I don’t want to show a text the user has already seen (I keep a counter of which the user has already seen in my users table)
Thanks @ThinhDinh! If I may borrow your brain a bit more, here’s where I am struggling:
I am trying to build a randomised journaling app where:
Users prefill 3 of their focus area when onboarding
I have a data table of prompts across a variety of areas
Every day / session the user gets 3-4 random prompts to start writing about (biased towards the user’s focus area)
Ideally, want to give the user an option to refresh the prompts if they don’t like any of the suggested 3-4, and pull a fresh set
Where I am stuck is how do I randomise, allow for refresh AND filter across two parameters - (1) - that the user has not already used the prompt (I update the used prompts in the user table) and (2) that majority of the prompts pulled are from the users’ focus area(s).
I was thinking of setting up a query to prefilter ‘available’ prompts (not seen + from focus areas) for each user and then randomise from that, but wondering if I am overcomplicating here. Even if I do go down this route, is there a way to randomise from the list specific to each user?
Yeah that’s what I advised you to do. You query out a list of available prompts for each user, you should be able to do that if you keep track of what users have already seen.
Then you just randomise from that list. It depends how you’re doing it, can be a collection with a random sort and limit to 3-4 items, it can be custom code to generate a list of IDs when the user clicks a button, etc.