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

Announcements

News and Announcements icon
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
    37,248 Super User 2026 Season 1 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#2
11manish Profile Picture

11manish 192

#3
Valantis Profile Picture

Valantis 128

Last 30 days Overall leaderboard