Filtering in Query not working for Tarot reading game

The filtering conditions in my query column do not seem to work properly. Here’s the situation:

  • I want to simulate a Tarot reading game out of a set of 22 cards
  • I’ve got 2 tables: “Valeurs aléatoires” and “mighty-match”
    • “Valeurs aléatoires” contains the infos on the 22 cars (title, picture, description) and one ‘ValAl’ column which is a randomized number to assign a single value to each card.
    • “mighty-match” contains the info on 3 cards: ‘CarteVM’, ‘CarteÉQ’ and ‘CarteOR’, i.e. the 3 cards I want to draw from the 22.
      • The ‘Seuil1’ and ‘Seuil2’ columns are thresholds I’ve set up to avoid duplicates between the 3 cards. THis is my ultimate goal: avoiding duplicates between the 3 cards.
  • Here is the query column in the “migthy-match” table:
  • For some reason, the resulting ‘card’ being queried has a ‘ValAl’ value that does not respect the “greater than ‘Seuil1’ AND lower or equal to ‘Seuil2’” (see last column in the “mighty-match” table).

Hi @Matt_Bister and welcome! :slight_smile:

Random calculation

Could you provide us the calculation you have applied for creating this column please?
Is it based on Row ID, on the current date and time?


Get 3 random rows (without duplicate)

Here is a slightly different approach you could use to make it works without these thresholds.
My concern is - depending on the way the ValAl result is calculated - you might find situations where no values match the condition (considering the Query provides the correct result). For example, you might not have any value below 350…

So another simple way to do that:

  1. Create a Start and and End (Number) columns and manually add the following values for each row (note: we do this manually because there are only 3 rows to fill, it’s also possible to make it dynamically, but let’s skip that for now on):

  2. Add a Query column (Top 3 ValeursAléatoires) to retrieve the first 3 values from ValeursAléatoires, sorted by ValAl (ascending or descending, that doesn’t really matter):

  3. Convert the result to an array using a Lookup column (Top 3 in array):

  4. Lastly, get the card for each row using a Slide Array (Carte from array):


You should obtain something similar to that table. No duplicate risk (if two or more rows have the same ValAl value, rows are gonna be then sorted by the table order and the query will still match 3 cards):


Fixed random?

That leads me to a last intriguing point: may I ask you how are you going to make the random value evolutive? Do you plan to use a button for example (which is often very convenient)?
Because unless I missed something, your values from ValAl are currently fixed for each row right? :thinking:


1 Like

Here’s my suggestion.

  • Create a template column and reference the current time, the rowID of each “card” and the signed-in user’s rowID.

  • Create a Roll Dice column based on the template “seed” we have above. The number of sides depends on you. You can set it to 22, or a very high number.

  • Then, query out the top 3 cards and show them to your user.

3 Likes

Many thanks @Nicolas_Joseph :folded_hands:t2: This makes a lot of sense.

Here’s the Math formula in the ‘ValAl’ column: CEILING(RAND()*1000)

With only 22 values, I’m yet to see any duplicate value in that column. But your way of doing it also prevents this from being a problem, as even if two values were to be equal, they’d still be ordered when sorting ascendingly or descendingly.

The refresh of that column (and the associated queries) is indeed the other issue I have. So far, I plan on simply opening a new tab with the app for the next user (quick note: they’re not ‘users’ as in ‘Glide users’; they’re just visiting the app once). This refreshes the column and assigns new cards to the new user. I’m actually not using ‘user-specific’ columns, but it stills works when I’m testing the app in different browsers.

The app will be used on Android tablets at an event, and eventually shared through individual emails (i.e. each user on their own device).

Thank you @ThinhDinh ! I didn’t think of the ‘Limit: 3’ parameter in the query, it was pretty much the missing trick also mentioned by @Nicolas_Joseph.

I don’t have logged-in users, but the fact that the ‘Current time’ includes the seconds could make this work in my case, in combination with the Roll dice (that I didn’t know about until now :folded_hands:t2:)

I’ll give it a try, thanks again.

1 Like

Happy to help! Current time will refresh every 10 seconds or so, and your random number will follow the same cycle.