Build a Secret Santa App in 20 Minutes or less with PowerApps
April Dunnam
Power Platform Advocate?? at Microsoft ? YouTuber ? Speaker ? LinkedIn Learning Course Author ? Low Code Revolution Host
It’s that time of year again, the holiday gift giving season has arrived. For some of you that means it's time for Secret Santa at the office. I decided this would be a great opportunity to showcase how quickly you can build an app with PowerApps. I'll walk you through how to create this Secret Santa app in PowerApps in 20 minutes or less.
I'm not going to go into all of the details of the app because I've put the completed PowerApp on my GitHub for you to download: https://github.com/aprildunnam/PowerApps. To use, just download the Zip file and upload it to your PowerApps Environment using the "Import App" option.
The first step is to create a place to store the data. While you could easily set this up in a SharePoint List, I decided to use Excel since that’s more readily accessible for most people. I created a new Excel Spreadsheet with the following 4 column headings:
- Name
- Gift
- SS
I put in one row of test data and highlighted the area and selected “Format as Table”. Make sure you also check the "my table has headers" checkbox. **This is a very important step because PowerApps will only recognize Excel as a data source if the data is formatted as a table.
Once the spreadsheet is configured, save it out to OneDrive. After downloading and importing my source code you will need to make sure you complete this step and change the data connection to point to your Excel file. Once you do that then everything else in the app should work.
Now that we have our back end configured, it’s time to create the front end using the blank phone app template in PowerApps. The Secret Santa app is comprised of 6 Screens:
- Landing Page
- Participants List
- New Participant
- Edit Participant
- Reveal
- Confirmation
On the Landing Page, I added a Label and set the text to “Secret Santa Helper”. I also modified the background color of the screen to a very Christmas-y red. Next, you need to add two button controls:
- Manage List - Directs user to the Participants list
- Draw - holds the logic to pick a random item from the participants list and directs the user to the results reveal page.
Most of the pages are pretty straight forward. The most important part of the app is the logic that gets the random item from the list which is activated on click of the Draw and Re-Draw buttons:
Set(varRandom,Last(FirstN(Filter(Table4,IsBlank(SS)), 1 + RoundDown(Rand() * CountRows(Table4), 0))).Name)
In the above code, I am setting a global variable called varRandom to the name of the random participant so that we can pass that value to the next screen. It is using the Rand() function in PowerApps along with the Last and FirstN functions to do the random logic. The Filter function is filtering out items from the list which have already been picked. When a user clicks the "Confirm" button on the Reveal page, that is setting the Secret Santa field to "Filled" to denote that the participant has been selected.
So, there you have it. With just a few steps you can have a fully functioning secret santa app in PowerApps!