web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Pick a random row on S...
Power Apps
Answered

Pick a random row on SP list filtering by column

(0) ShareShare
ReportReport
Posted on by

Hi,

i'm making a trivia app where users can answers to questions and check their score.

 

The Questions are stored inside a DB made with a sharepoint list that has the following structure

  • QuestionID - an INT number that autoincrements
  • QText - a string
  • Topic - a string value that store the topic of the question
  • and more...

 

When the user decide to play, the questions are retrieved making a simple lookup with a random value that is generated picking a value from 1 to the count value of the Sharepoint list

//retrieve the total number of questions in the DB
UpdateContext({QuestionsCount: CountRows(QuestionsDB)});
//set the current question ID picking a random number between 1 and QuestionsCount
UpdateContext({CurrentQuestionID: RandBetween(1,QuestionsCount)});
//retriving the question text
LookUp(QuestionsDB,Text(CurrentQuestionID) = QuestionID).QText})

 this is working fine but i want to make also a special type of game where the user can pick questions related to a single topic.

What's the best way to filter?

 

I could store all the filtered questions inside a Temp collection but then i won't be able to pick the random question using a rand between 1 and Collection Count because many ID would be missing.

what do you suggest?

 

thanks

Categories:
I have the same question (0)
  • Verified answer
    timl Profile Picture
    36,393 Super User 2025 Season 2 on at

    Hi @Antonioclk 

    Rather than choose a random question based on QuestionId, you could call the Shuffle function to return a random question.

    First(Shuffle(QuestionsDB)).QText

    By using this method, you can then filter QuestionDB to return only those that match a certain topic.

     

    First(Shuffle(
     Filter(QuestionsDB,
     Topic = "Sport"
     )
     )
    ).QText
    
    
  • Antonioclk Profile Picture
    on at

    thanks it worked perfectly

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard