Randbetween of a list

Hi Team,
how can i do a randbetween of a list? its possible?
and then eliminate this number of the list.
br

2X_2_2f0bd9c889cf49dea630ec99b821b2ee2549f5ff.png

0 24 1,244
24 REPLIES 24

You can use the function like this:

RANDBETWEEN(1, COUNT([List]))

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

INDEX([List], RANDBETWEEN(1, COUNT([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

@WillowMobileSystems,

Good one. Nice practical solution.

2X_c_c7b24e0df56e17e39762a8ba519e5804c0eb7d7b.jpeg
Hi John Baer,
thks but,
whats about this error?
br

[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.


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?
br

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]))

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.

br

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

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โ€?

br

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?

smart solution

No Steve, key column is โ€œrow_numberโ€.
To check it quickly i simplified situation using only one player.

2X_b_b5c2da87ec6cdef0b9c6ba3e2a3225d89376a84b.png

Try:

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

[card] as enum list type?

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?

Itโ€™s documented:

2X_7_7dc1fe8a8e84e3dd40944b14abff6ed92431c7fa.png

2X_8_894e1ea74b8047c7c464664103eb9230e0274a10.png

Hi Steve,
the result is ok for you? it seems ir running,
but for my use is not ok , i need another column with only the new card.

I attaches you an example [onlyCard].

br

2X_2_26228ad97c92a0c9ccd6b9a0d1a6da01a1c41dcb.png

Top Labels in this Space