Generating a random number and then one based on that number

Hi! I’m using RandBetween() to make my app pick a quote randomly from a column. That’s easy enough. Let’s say I have 120 quotes and I want to make a slice that will pick out just one record to display in the detail view that is shown when the app is opened. I number the [Key] column from 1 to 120 and used this make the slice:

[Key]=RANDBETWEEN(1,120)

So far so good. Actually, though, I would like the slice to result in two records – the English quote and a corresponding Japanese translation. The English should display first, as the default, and my Japanese users should be able to swipe to see the second record with the Japanese.

I have a solution and my question is “Is there a better, simpler way to do this?”

My solution: I put the corresponding Japanese translations into records, in the same column on the same table, that equal the English key + 1000. So, the record with the Japanese translation for quote no. 24 would be 1024. I wanted to use RandBetween to find the number for the English quote and then add 1000 to that to find the Japanese quote. Unfortunately, however, if I use RandBetween twice I’ll get two different numbers. So, I put RandBetween() in virtual column in another table (a very small one – only a couple of records). That happens to be a table called “Stats” and I named the virtual column “Random no for Welcome”. Here’s the expression I’m using now:

or([Key]=number(SELECT(Stats[Random no for Welcome], ([_RowNumber] = 2))),[Key]=number(SELECT(Stats[Random no for Welcome], ([_RowNumber] = 2)))+1000)

It works but, as I wrote above, I’m wondering if there might have been a simpler solution. Thanks for your consideration.

P.S. I used to do this on the spreadsheet side but I would prefer to do this all within AppSheet. Relying on the spreadsheet causes minor problems I’d like to avoid.

Also, the following post also deals with the issue of how to get an app to open with a random quote, but the specific question I’m posing here isn’t addressed:

1 22 4,002
22 REPLIES 22
Top Labels in this Space