Showing results for 
Search instead for 
Did you mean: 

PowerApps Pro Tips | Using Variables

Like parameters, variables are very helpful, and can be used to increase user communication in your app. A variable in Microsoft PowerApps is used with the function UpdateContext. Below are a few ways you can start using variables immediately in your apps.


User Communication

In a scenario where you’re sending data back to a source and doing a Patch, at times the user can be confused about what’s happening (if anything is going on at all).  You might not want to take a user back to another page until the Patch is complete. To more effectively communicate to the user what is happening, try the following:

  1. Create a new app
  2. Add a data source
  3. Add a button that will send a record back to a source
  4. Add the following code before your patch runs: UpdateContext({MyVariable:”Sending Data”});
  5. Add the following code after your patch runs: UpdateContext({MyVariable:” “})
  6. Update the Button Text to: If(MyVariable = “Sending Data”,MyVariable,”Send”)

Now your user will see the button change text to let them know what is happening.


Sending Data from Page to Page

There may be times when you want the user to interact with data on screen 1, then pass some information to screen 2 based on an interaction on the first screen. This becomes useful when you have a list of items on the first screen, and you want to show details on the second screen. To try this out, use the following steps:

  1. Create a new app
  2. Add two screens
  3. On the first screen, add a drop down
  4. The OnChange property needs this: 
  5. On the second screen, add a text box
  6. Set the text property to: MyVariable

Now you can pass variables from page to page. Variables will only live on that page that you are on. If you need global variables, then you can use a collection.


Written by Power User and Managing Partner Evan Chaki, this post was originally published on the Confluent blog. Browse the blog for additional PowerApps Pro Tips, and let us know what topic you'd like to see next!

Meet Our Blog Authors
  • PowerApps Community Mentor 2018, Practicing surgeon and former Professor of Surgery, University of Illinois, Chicago.
  • Jill of All Trades (Power Apps, SharePoint, PowerShell, Exchange, Power Automate and odds & ends of assorted other things)
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • I'm Tim Leung - a PowerApps builder. In addition to PowerApps, my main interests include building software with SQL Server and Microsoft .NET. I'm the author of 'Beginning PowerApps' - the first published book on PowerApps. You can buy this from Amazon and other leading bookstores.
  • Systems developer
  • My name is Timothy Shaw and I create digital solutions using the Power Platform, Office 365, and Azure SQL and handle the IT for a small company in the energy sector. When not building the future :), I enjoy playing guitar, good (or really bad!) sci-fi, Xbox therapy, and hanging with my wife and son. Twitter: @ShortForTim