Select a random row of a table

Example 4: The final solution: 1 Table 1 Button
This is not how I used it in LIP2, because with the game board and the object list, I needed two tables anyway, but in many cases you only need one like here. The principle is quit the same as in the examples before, but here we use a timestamp to mark eaten rows and to create an order and see which is the current one.

I created it with vegetables this time:

  1. Create a table vegetables with the columns “id” (row properties -> row id), “name” (text), “order” (=random()) and “selected” (date/time)
  2. create a button with “modify rows”, select the vegetables table and the custom filter id=Vegetables.filter(selected="").sort(false,order).id.last() (this time we select by id, to make it possible to have a vegetable more than once)
  3. use the values: “selected = now()”
  4. you can also add a disabled if: Vegetables.filter(selected="").count()=0
  5. create a formula on your canvas =Vegetables.filter(selected!="").Sort(true,selected).name.last()
4 Likes