Display a single, random row from a Slice

I have a Slice set up with expressions to filter out some records from a table.

I want to display a single, random row from that Slice within a View.

How would I go about doing this? I’ve seen the thread “Pick a random row from a table” but I don’t know where to enter this expression. I added it as a formula in a virtual column in my table, but that doesn’t seem to be getting me anywhere. Any help is appreciated!

Maybe make another Slice, with a row filter condition of:
[key-column] = /random-row-selection-expression/

There should be only 1 record in the new Slice.
Make a new UX->View based on the new Slice.

3 Likes

You have mentioned that you already have a slice set up to filter some records. It sound that you wish to now further include a condition of any random row among the filtered records. If so, you will need to combine your existing slice filter expression and the expression that selects a random value as mentioned in post by @TyAlevizos , that you have referred.

Your slice filter condition can be something like

[Key]=INDEX(SELECT(Table Name[Key], [Status] =“Open”), RANDBETWEEN (1, COUNT(SELECT(Table Name[Key], [Status]=“Open”))))

Here [Status]=“Open” is equivalent to your existing filter condition. Please replace it with the actual filter condition you have.
Basically , the combined expression selects records from the table based on your required condition and then among those selected records , the RANDBETWEEN() combined with INDEX() selects a random record.

3 Likes

@Marc_Dillon

Sorry, as I tested the expression and typed the response, I did not see you have already replied.

3 Likes

Thanks so much @Marc_Dillon and @Suvrutt_Gurjar!! This helped me work it out. I greatly appreciate your responses.

2 Likes