Randbetween of a list

You can use the function like this:


Then use the INDEX function to get that item in the list:


Then you can subtract it from the original list but the item has to be in LIST form

[List] - LIST(INDEX([List], RANDBETWEEN(1, COUNT([List]))))

NOTE: I have not tested this



Good one. Nice practical solution.

Anotació 2020-04-10 230034
Hi John Baer,
thks but,
whats about this error?

[List] was my generic reference to some list variable. You need to replace it with whatever your list is. It could be a SELECT() function or a column of some LIST type like EnumList.

1 Like

Hi John,
I don’t know where I’m wrong
i’m attaching you 4 results.
and I dont know how to use index option?

In your examples, for each of the columns A, B, C and D, it seems you are reusing the RANDBETWEEN function each time which means it re-generating a new random number in each column.

You need to use the saved [randomNumber] value in columns C and D. For example in Column C the expression should be

INDEX([initialList], [randomNumber])

The expression in Column D should be:

[initialList] - LIST(INDEX([initialList], [randomNumber]))

1 Like

I quickly implemented this in a tester app. It appears to be working well. Note how it works when the list is not in sorted order.


thks a lot John for your help,
its running.

Hi John,
and now, how I can not repeat randomNumber? its possible?
My initial idea was to use [newList] as [initialList] but its impossible, its a circular definition and not works.


What are you trying to accomplish here? Something like shuffle play a playlist?

smart solution

Hi Steve,
I have 10 differents cards and 2 players, and i want to deal the cards.

Suppose a Cards table has the columns: Suit, Value, and ID (the combination of the suit and value); and 52 rows for a common deck of cards. To deal player 1, set Player 1 Hand to the output of:

TOP(ORDERBY(Cards[ID], RANDBETWEEN(1, 999999)), 5)

and to deal player 2, set Player 2 Hand to the output of:

TOP(ORDERBY((Cards[ID] - [Player 1 Hand]), RANDBETWEEN(1, 999999)), 5)

See also:


Hi Steave,
why using “TOP(ORDERBY(Cards[ID], RANDBETWEEN(1, 999999)), 5)”,
appears this message “ORDERBY has invalid inputs”?


Did you replace Cards[ID] with the appropriate column specification for your app?

Yes I did.
top(orderby(game[card],RANDBETWEEN(1, 999999)), 5)

The the Card column the key column of the Game table?

No Steve, key column is “row_number”.
To check it quickly i simplified situation using only one player.



top(orderby(game[_rownumber],RANDBETWEEN(1, 999999)), 5)

This looks interesting. I don’t understand how passing a number as the 2nd argument to ORDERBY() works though? Is this an un-documented feature?