Compare randomly chosen items from same collection

i want two randomly chosen entries from the same collection displayed - for the user to chose 1

  • when they click on one the page refreshes and another two are shown - with never the same item in both spots ? - any ideas how I could achieve this? - i thought a list - with only 2 items shown (and no sorting)- but then not sure how to get this to refresh and show another 2 items - randomly selected…

Hi @eyedeer,

This is an interesting and non-trivial question. I decided to make an experiment and publish a video about it. Enjoy: https://youtu.be/t6_UeckEZOc

Best regards, Victor.

1 Like

@Victor Thank you, Thank you, Thank you.

  • Just one question …
    If the lists have items in them that can be created and deleted by users …
    I may end up with holes in id numbering - do you know if this will confuse the random picker?

Kind Regards
Brooke

Hi Brooke @eyedeer,

This wasn’t in the original requirement :grin:

Speaking seriously - item creation should not break this, as long as you assign ID automatically based on ID → Maximum → + 1 (or Count +1).

But deleting items will definitely break the solution: it’s not the random picker, but rather the list which will not display the item with nonexistent ID.
And here unfortunately no easy solution comes to my mind.

  • You could try to recalculate ID for all the collection, but this will require some external service.
  • You could try to mark items as “deleted”, and after the random picker chooses the value, check if the item is “deleted” and re-choose the value. This could be done with similar logic which I showed (additional condition on screen enter). But if users delete items frequently, the “ID re-selection loop” will happen too often.
  • Another option - use external service, like Integromat or Zapier, to make the random choices
  • May be storing the records in Airtable could help - so that upon deletion you could implement some Airtable functionality to auto-update the IDs. But I’m not sure if this is possible or not.

Best regards, Victor.

1 Like

@Victor Thanks for all your help!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.