Help with RANDBETWEEN expression

I have an onboarding view that displays one quote from a table of quotes. Since you can’t get rid of the Back button on Onboarding Views, I want it to display two quotes instead of one. At least the back button makes sense then.

Here is the row filter expression for the slice the view is based on.
AND([SORT_ORDER]=RANDBETWEEN(1,MAX(Encouragement[Sort_order])),[IN_APP]=TRUE)

How can I change it to pick two?

Thanks.

The problem here is that the slice filter expression is evaluated anew for each row, so each evaluation will get a different result for from RANDBETWEEN(), and there’s no way for one row to know what another row got.

My suggestion is to add a virtual column to the Encouragement table named (e.g.) Random_order with an App formula expression of RANDBETWEEN(1, 999999). Then make your slice row filter expression:

IN(
  [_THISROW],
  TOP(
    ORDERBY(
      FILTER("Encouragement", TRUE),
      [Random_order],
        FALSE,
      [_ROWNUMBER]
        FALSE
    ),
    2
  )
)
1 Like

Thanks Steve. That is a huge help. My brain would not have been able to figure that out, at least not today.

1 Like