Build a Secret Santa App in 20 Minutes or less with PowerApps

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.  Today I will walk you through how to create this Secret Santa app in PowerApps in 20 minutes or less:

I've put the completed PowerApp on my GitHub which you can find here:  You can 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
  •         Email
  •         Gift Idea
  •         SS
I put in one row of test data and highlighted the area and selected “Format as Table”.  This is a very important step because PowerApps will only recognize Excel as a data source if the data is formatted as a table.  

Make sure you format your data as a table so PowerApps can recognize it as a data source

Once the spreadsheet is configured, save it out to OneDrive.  If you are downloading and using 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 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:
  1. Landing Page
  2. Participants List
  3. New Participant
  4. Edit Participant
  5. Reveal
  6. 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. 
This is the logic that draws the random item from the list:

Set(varRandom,Last(FirstN(Filter(Table4,IsBlank(SS)), 1 + RoundDown(Rand() * CountRows(Table4), 0))).Name)

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!