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 / Creating a randomised ...
Power Apps
Answered

Creating a randomised subset of data

(0) ShareShare
ReportReport
Posted on by 11

I am learning MS Power Platform and am currently learning about PowerApps.

 

I tend to learn more efficiently by actually making things rather than reading or watching others, so I thought I'd have a go at making a canvas app and learn as I go.

 

As I'm going to be sitting a few exams at the end of this, I thought it would be fun and useful to make a 'flashcard' app.

I was hoping to use the Dataverse as my data-source, but I do not have permission to add tables. I then thought I'd use a SharePoint list, but it's the same problem, so I ended-up using an Excel spreadsheet on my OneDrive to hold the data.

 

I have created the spreadsheet and PowerApps did the hard work of creating the screens for the CRUD operations for adding and editing the flashcards. I've managed to add some validation and added a few small scripts for default values etc. but I am now at the stage where I need to create the actual game, and I've realised this is a bit beyond my own ability to figure-out, so I was hoping somebody could point me in the right direction how to go about this?

 

I've attached some screenshots to help explain, but I would like the home-screen to allow users to select which subject(s) to be tested on and how many questions, then for PowerApps to grab a randomised subset of data from the spreadsheet and then go through them one at a time, giving the users the question followed by the answer (when ready) and hopefully keep track of the score too.

 

Is this possible? I hope I haven't been too ambitious with my first app. Any advice would be gratefully received, thanks!

homescreen.jpg
answer.jpg
question.jpg
Categories:
  • Verified answer
    BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @Kylo_Stimpy ,

     

    First off: this is a really cool idea and your mock-up looks great.

     

    To get a random sub-set out of your questions, you can use something like the below:

     

    ClearCollect(
    	colQuestions,
    	FirstN(
    		Shuffle(
    			Filter(
    				QuestionsDataSource,
    				Subject in cbdSubject.SelectedItems
    			)
    		),
    		Slider.Value
    	)
    )

     

     

    First this filters the questions per selected subject in the Subject Combo Box (you probably need to change the identifier in the code). This filtered set is then randomised using the Shuffle function. The FirstN function is used to select the right number of questions as submitted by the users in the Slider. Finally all is saved in a collection which can then be used in your app.

     

    The reason to use a collection is because it will give you a snapshot, preventing duplication of questions.

  • Kylo_Stimpy Profile Picture
    11 on at

    Hi @BCBuizer

     

    Thank you for your reply, this is a great start - I will go and have a play around to see if I can apply this to my app.

     

    I think I should be able to understand the collection idea and syntax (with a bit of trial and error, but that's my favourite way of learning) but I think I may need a further pointer to how I can 'run through' this collection one card at a time once I've built the collection from the form controls' values.  Any tips on where to start would be appreciated.  Thanks again!

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @Kylo_Stimpy ,

     

    You can run through the collection using the Index function and a variable as a counter. Let's say we have variable (varCounter) which is initiated at a value of 1 in the App.Onstart property:

     

    Set(varCounter,1)

     

    Once the user has selected the subjects and number of questions on the Home screen, the OnSelect property of the Play button should initialise the collection using the previous code and navigate the user to the question screen.

     

    In the question screen, the right question can be selected using:

    Index(colQuestions, varCounter)

    In the same screen varCounter can be used for other things like the progress tracker on the top left of the screen and to determine if the user has reached the last of the questions.

     

    A mechanism should be added to navigate through the questions, for instance by using a Next button with the below OnSelect property:

     

    If(
     varCounter = Slider.Value,
     Navigate(Result screen),
     Set(varCounter, varCounter+1)
    )

     

    As you can see an If statement is used to determine whether there's a next question, or something else needs to happen. In the above example the user is taken to another screen to review the results.

  • Kylo_Stimpy Profile Picture
    11 on at

    @BCBuizer 

     

    This is brilliant, thank you - enough information to get everything working (but still loads to figure-out myself, which is great for learning).

     

    The app is now finished and working as expected. I'll have you know it only took two full days of trial and error 😁.

    I've got a few ideas to expand it further when I get some more time.

     

    I'm not sure which of your comments to mark as 'solved' - I think I'll do the first one. Are you able to edit your posts? There was a comma  after the ClearCollect bracket that I don't think should have been there, and also for the combobox I had to use 

    in cbdSubject.SelectedItems

     rather than 

    in cbdSubject.SelectedItems.Value

     for it to work, but other than that everything was spot on.

     

    Thanks again for your assistance with this.  This has been a huge help with my learning.

  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @Kylo_Stimpy ,

     

    Really happy to have been of your support.

     

    I have updated my first post with your feedback: the comma was a typo and I figured the Subject column was a Text type, but it seems it was actually a Choice type.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 239

Last 30 days Overall leaderboard