Hi Team,
how can i do a randbetween of a list? its possible?
and then eliminate this number of the list.
br
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
Good one. Nice practical solution.
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.
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.
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:
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
User | Count |
---|---|
40 | |
28 | |
22 | |
20 | |
15 |