Hi everyone! I need your help (I am fully new so excuse me if my question is too silly…)
I am building an app that has to pick 2 random items from a column (i have 3 columns in my table, 1 with the items, and other 2 single value, configured to get Randomly from the first one).
Sometimes the app chooses to pick the same 2 items (that is, the random number generated is the same), and i need 2 different items. I can´t figure out how to avoid the app to choose the same value for both.
Also, i want the full process to rebuild by clicking a button, that is, to remake the single value columns and pick again 2 items, without log out and in again in the app.
Any help would be much appreciated! Thanks for reading me, hope i could explain my issue well. Goodnight everyone
Yep I gave this a go after seeing a similar topic elsewhere, but unfortunately it didn’t do the trick.
It may be because of how I’ve structured the front-end. The ‘questions’ in the screenshot below are 3 random questions from a list of questions. So I need to find a way that randomises the questions when the user clicks on the button (for now, I don’t mind if it repeats one or two when randomising).
Try this. Create a user specific text column in your screen table. Then create a single value column that populates that text value across all rows. Then change your button action to Set Column and have it set the user specific column with a Unique ID.
Whenever you press the button, what it should do is update the user specific column, which will update the single value on all rows. This will cause each row to re-compute, which should re-randomize the random value.
Oh I see, i.e. since the single value column is a computed column of sorts, then that changing should in theory re-computer all the other single values which I use for the questions?
I gave it a go as per the below, is this what you meant? The screen table I’ve been using is a single-row working table, which then populates a separate table once the user submits the form with the submit button (separate to the ‘randomiser’ button). It seems the questions aren’t changing when I get the randomiser button to set the column value of ‘reset text’ to a different unique ID, so maybe I’ve done it incorrectly.
Yes, exactly, that was the theory. Seeing that you are only working with a single row, then I guess the first single value column with a unique ID is unnecessary since you are updating the reset column in that same row.
I don’t think you are doing anything incorrectly. I may just have to play around some more to find a solution. I had done a quick test by changing the value in a template column, and that was causing the random single value columns to change, so I had assumed that any update in a row would cause the random to trigger. I may have assumed wrong.
Another thought off the top of my head would be to create three columns to hold 3 unique ID’s, set those three unique IDs with the button, then create 3 random number generator columns seeded from those unique IDs, then set the single value question columns to pull a value based on each respective random number. A bit messy, but wouldn’t solve the duplicate question problem.
I’m wondering if there’s a way to do something like this, and also use an ITE column to identify if there is a duplicate - if so, then it randomises again, and repeats until it lands on something that isn’t a duplicate? Not sure how doable this is, aside from it being a messier solution
Sorry for the delay. Finally got some free time to work on this.
Copy the app, have a look at it, and see if you have any questions.
If anybody has better code, feel free to share. This was just something I threw together quickly. Essentially it gets a random question from an IN array, adds it to an OUT array, and removes that question from the IN array, so the next random won’t grab a question that’s already been selected.
Side note, if Glide fixes the shuffle issue, then there may be a possible chance that we could eliminate the unique ID and go back to using the shuffle action. Something to keep it mind as it may save on update counts.