Fun with Power Apps: Build a Random Cat Holiday Greeter
Combine your love for cats and low-code with this easy Power Apps project. Learn how to use collections, random selection, and galleries to create a festive seasonal app.
The holiday season is the perfect time to blend fun with learning. In this tutorial, you'll build a "Catmas Greeter" – a Power Apps app that selects a random cat image and a cheerful holiday message. It's a great way to practice working with collections, random functions, and gallery controls. Plus, you'll have a shareable greeting card to delight your colleagues.
Setting Up the Collection
We'll store our cat images and messages in a collection called CatmasData. Each record will contain two fields: CatPhoto (a URL to an image) and Greeting (the message text). You can use any hosted cat images – placekitten.com is a convenient option for prototyping.
Writing the OnStart Logic
Open your app and paste the following code into the OnStart property of the App object. This populates the collection and initializes a variable that holds the currently displayed greeting.
ClearCollect(
CatmasData,
{
CatPhoto: "https://placekitten.com/400/300?random=1",
Greeting: "Have a purr-fect holiday!"
},
{
CatPhoto: "https://placekitten.com/400/300?random=2",
Greeting: "Meowry Christmas and a Happy Mew Year!"
},
{
CatPhoto: "https://placekitten.com/400/300?random=3",
Greeting: "Stay cozy and warm this winter!"
}
);
Set(CurrentGreeting, First(CatmasData));Use your own images by uploading them to the app's media resources or linking to an image hosting service.
Building the User Interface
Add a vertical gallery to your screen. In its Items property, type [CurrentGreeting]. The square brackets wrap the single record into a single-row table, which the gallery expects.
Inside the gallery, place an Image control and bind its Image property to ThisItem.CatPhoto. Below it, add a Label and set its Text property to ThisItem.Greeting. Resize the controls to fit your layout.
Adding Random Selection
Now add a Button labeled "New Greeting". Set its OnSelect property to the following formula:
Set(RandomIndex, RandBetween(1, CountRows(CatmasData))); Set(CurrentGreeting, Index(CatmasData, RandomIndex));
The RandBetween function picks a random integer between 1 and the total number of records. Index then retrieves the record at that position and stores it in the CurrentGreeting variable, instantly updating the gallery.
Enhancing the Experience
Add a splash of holiday magic with a festive background color or a subtle animation. You can also include a second label that displays the date or a countdown to New Year's. For a more dynamic app, replace the static collection with a SharePoint list or a Microsoft List so team members can contribute their own cat photos and messages.
Common Pitfalls
- Gallery Items as single record: Remember to wrap
CurrentGreetingin square brackets. Without them, the gallery will treat the record as a single row and not iterate. - Collection not being populated: Ensure the
OnStartcode runs before you open the app (select File > Reload if needed). - Image not displaying: Confirm that the URL is accessible from your users' environment and that you're not using a relative path. For local images, reference them by their resource name.
Wrapping Up
You've created a simple, playful app that showcases core Power Apps skills: collections, variables, random selection, and gallery binding. Feel free to expand the collection with dozens of messages, add a "share via email" flow using Power Automate, or embed the app in Microsoft Teams for your team to enjoy.
The best projects are those that bring a smile – and a few cat puns – to your workplace.
References
- Original source: Matthew Devaney, Merry Catmas! (URL not available)
- Microsoft Learn: Collect, Clear, and ClearCollect functions
- Microsoft Learn: Random numbers and RandBetween
How I went from a CPA obsessing over spreadsheets to a full-time Power Platform developer by building apps on nights and weekends.
Ring in the New Year with a playful Power Apps greeting that showcases your customization skills and spreads cheer.
Inspired by a recent appearance on the XRM Toolcast, here’s a practical guide to choosing custom pages for your Power Apps solutions—no chicken sandwiches required.