Pick a random row from a table

To pick a random row of data from a table, the ANY() function will not suffice. Here’s a simple pattern to do this:

index(Test Score[Key],
randbetween(1, count(Test Score[Key]))
)

Where “Test Score” is your table name and “Key” is that table’s key.

This sample app shows this in two ways:

  1. We format a row randomly. When you resync the app, a new random row will be selected each time (in bold red)

  2. We have an icon on the left side of the table which will assign a “person” to the “test score” randomly.

This comes up from time to time in various situations and I didn’t see an existing forum post. As usual, chime in if you have a better version!

6 4 1,127
4 REPLIES 4

NICE! This is like one of those perfectly reduced forms of an expression. It’s the cleanest, shortest way you could randomly select a record from a list of unknown length.

…for now

Maybe this should be a feature request!

RANDOM({list}) where the list could be a SELECT, FILTER, or any other list. And the value returned has the corresponding data-type of the source column (list of Refs, dates, etc).

Steve
Platinum 4
Platinum 4

Or:

ANY(
  ORDERBY(
    Test Score[Key],
    RANDBETWEEN(1, 999999)
  )
)

How do i get the return label column vs displaying the key column?

Top Labels in this Space