The Shuffle function in PowerApps is used to randomly reorder the records in a table. This can be particularly useful for scenarios like creating randomized quizzes, shuffling items in a gallery, or generating random orders for any collection of items.
PowerApps – Shuffle() function Syntax
- Table: The table or collection that you want to shuffle.
Notes:
- Empty Tables: Ensure the table you are shuffling is not empty to avoid unexpected results. You can use IsEmpty to check:
If(!IsEmpty(Questions), Shuffle(Questions))
- Consistent Shuffling: If you need to ensure the shuffle results are consistent within a session, set the shuffled table once and use it throughout the session.
PowerApps – Shuffle questions from collection
Suppose you have a collection named Questions and you want to shuffle the order of the questions:
This returns a new table with the questions in a random order.
PowerApps – Shuffle Items in a Gallery
If you have a gallery control named Gallery1 bound to a collection named Products, and you want to display the products in a random order:
// Set the Items property of the gallery
Shuffle(Products)