Power Apps global vs context variables comes down to scope. Set() creates a global variable that every screen can read, while UpdateContext() creates a context variable that only the screen where you set it can read. Collections are a third option for tables.
// Global: readable on every screen
Set(gblCurrentUser, "Megan Bowen")
// Context: readable only on this screen
UpdateContext({locClickCount: locClickCount + 1})
// Collection: an app-wide table
Collect(colVisited, {Title: "VPN access #1001", Requester: "Alex Wilber"})
I tested all three in a demo canvas app. gblCurrentUser returned Megan Bowen on every screen, locClickCount reached 3 after three clicks, and colVisited held 2 rows after two runs.
Build the Demo App Step by Step
New to canvas apps? Here’s how I built the test app, so you can follow along. Our Power Apps tutorials cover each control in more depth.
1. Prepare the data. A data source is where the app reads and writes records. Mine is a SharePoint list called Service Requests with 620 items and columns like Title, Status, Priority, Requester and DueDate:

2. Open the maker portal. Go to make.powerapps.com, stay on Home and look for Start with design:

3. Start a blank canvas app. Select Create, then Create from blank (canvas app):

4. Choose a layout. In Start with a blank canvas, pick Tablet:

5. Add the data. Select Add data, search for SharePoint and pick the SharePoint connector:

6. Connect to the site. Paste the SharePoint site URL and select Connect:

7. Pick the list. Check Service Requests and select Connect:

8. Add controls. The Insert menu has every control: Text label, Text input, Vertical gallery, Date picker and Button. I added four buttons and a few labels:

To give a control a formula, select it, then pick the property (such as OnSelect or Text) in the dropdown left of the fx formula bar at the top. Type the formula in the bar.
To run a button, select Play (the preview button, top right) and click it, or hold Alt and click it in the editor. Press Ctrl+S to save.
My scrVariables screen has four buttons on top: Set global, UpdateContext +1, Collect a row and Navigate with context. Labels below show each value. Here it is in preview after a few clicks:

Power Apps Variables at a Glance
Power Apps has three kinds of variables. You don’t declare any of them. A variable exists because a formula mentions it in one of these functions, and its type comes from the value you give it.
| Global variable | Context variable | Collection | |
|---|---|---|---|
| Created with | Set | UpdateContext, Navigate | Collect, ClearCollect |
| Scope | Whole app | One screen | Whole app |
| Holds | Any value: text, number, record, table | Any value: text, number, record, table | A table you can add rows to |
| Clear it | Set(x, Blank()) | UpdateContext({x: Blank()}) | Clear(col) |
| Typical use | Current user, app settings | Popups, toggles, screen state | Cart, offline lists, lookups |
All three start blank when the app opens and live in memory until the app closes. Nothing survives a restart unless you save it to a data source.
You can also set several of them in one formula, as shown in our guide to set multiple variables at once in Power Apps.
How Do Global Variables Work in Power Apps?
A global variable is set with Set(VariableName, Value). You can only call it in a behavior formula, such as a button’s OnSelect, a screen’s OnVisible or App.OnStart. The value is then readable from any screen.
In the demo, the Set global button’s OnSelect is Set(gblCurrentUser, "Megan Bowen"):

To show it, I set a label’s Text property to "gblCurrentUser = " & gblCurrentUser. The & operator joins text:

In a real contoso.com app, you’d read the signed-in user instead of typing a name:
Set(gblCurrentUser, User().FullName);
Set(gblIsManager, User().Email = "megan.bowen@contoso.com")
A button’s Visible property can then use gblIsManager, the same idea as our post on how to show or hide a button for the current user.
Global variables don’t recalculate on their own. If User() or a list changes, the variable keeps its old value until another Set runs.
How Do Context Variables Work in Power Apps?
A context variable is set with UpdateContext(), which takes a record. A record is one row of named fields in curly braces. Each field name becomes a variable on the current screen.
My UpdateContext +1 button adds one on every click:

After three clicks in preview, the label bound to locClickCount showed 3. Other screens can’t read it.
You can set several context variables in one call, such as UpdateContext({locShowDialog: true, locSelectedId: ThisItem.ID}). Variables you don’t name keep their current values.
Context variables are perfect for screen-only state. A delete confirmation is the classic case: the Delete button sets locShowDialog to true, and the dialog’s Visible property reads it. Our Power Apps popup message walkthrough builds exactly that.
One detail many blogs get wrong: a context variable doesn’t reset when the user leaves the screen. Per Microsoft, it keeps its value until the app closes, so the popup is still open if the user comes back.
Close it explicitly, for example in the screen’s OnHidden property:
UpdateContext({locShowDialog: false})
Pass a Context Variable With Navigate
The third argument of the Navigate function in Power Apps is a record that sets context variables on the target screen. It works like UpdateContext, but for the next screen. My Navigate with context button uses it:

Navigate(scrVarDetails, ScreenTransition.None, {locSelectedTitle: "VPN access #1001"})
In preview, the details screen showed the passed value next to the global variable, which needs no passing at all:

In a real app you’d usually pass {locOrder: ThisItem} from a gallery. This is the only way to set a context variable from outside its screen.
Use it when a screen needs one or two inputs, like the selected gallery item. If five screens need the same value, a global variable is simpler.
Collections: When a Variable Should Hold a Table
A collection is an in-memory table that the whole app can use. Unlike a variable, you can add, change and remove rows one at a time. Start with our guide to create a collection in Power Apps.
My Collect a row button appends one record each time:

Two clicks gave colVisited 2 rows. Collect appends; ClearCollect empties the collection first, then adds:
ClearCollect(colVisited, {Title: "VPN access #1001", Requester: "Alex Wilber"})
To change one row later, use Patch or UpdateIf on the collection, as in our post on how to add and update items in a Power Apps collection.
How Do You Update One Field of a Record Variable?
When a variable holds a record, you can’t assign a single field directly. Wrap the record in Patch and set the variable again with the merged result:
Set(gblRequest, {Title: "Laptop replacement #1000", Status: "New", Requester: "Megan Bowen"});
Set(gblRequest, Patch(gblRequest, {Status: "Closed"}))
In the demo, the Set record variable button runs the first line and the Patch one field button runs the second:

The label that joins the three fields changed to Laptop replacement #1000 | Closed | Megan Bowen, so only Status changed. The same pattern works for context variables:
UpdateContext({locRequest: Patch(locRequest, {Status: "Approved"})})
This only changes the in-memory copy. To save it to SharePoint, patch the list itself; our post on the ways to use the Patch function in Power Apps covers that.
Global vs Context Variables: Which One Should You Use?
Here’s the quick rule I follow on client apps:
- Global variable: a single value or record that several screens read, like the signed-in user, a selected department or a theme.
- Context variable: state that belongs to one screen, like a popup flag, an edit mode or a tab index.
- Navigate argument: one-off input for the next screen, like the item a user tapped in a gallery.
- Collection: a table you’ll add rows to or edit row by row, like a cart or offline queue.
Microsoft’s own advice is to avoid variables when a formula can do the job. If a label can show Gallery1.Selected.Title directly, you don’t need a variable at all.
And if the value never changes after the app starts, a named formula is usually better than Set. More on that below.
Name Variables With gbl, loc and col Prefixes
Power Fx doesn’t require prefixes, but they make formulas readable at a glance. A common convention:
gblorvarfor global variables:gblCurrentUserlocfor context variables:locShowDialogcolfor collections:colCart
Prefixes also prevent collisions. If a context variable has the same name as a global variable or collection, the context variable wins on that screen. Use the disambiguation operator to reach the other one:
[@gblCounter]
Our Power Apps naming conventions guide covers controls and screens too. If you need to fix names in an existing app, see how to rename variables in Power Apps.
See Variable Values in the Variables Pane
In Power Apps Studio, select the Variables icon ({x}) on the left rail. In my app, it lists Global variables, Named formulas, Context variables (grouped per screen), Component variables and Collections:

Each entry shows its type and value: gblCurrentUser is Text (Megan Bowen), gblRequest is a Record, locClickCount under scrVariables is Number 3, and a collection shows its row count, such as Table: 620 rows.
Select a variable to see its current value and every place it’s defined and used. That’s the fastest way to find which button keeps changing gblRequest.
Values only appear after the formula that sets them has run. Preview the app or Alt+select the button first, and run Run OnStart from the App object’s … menu in Tree view to fill start-up variables.
Named Formulas: A Modern Alternative to Set in App.OnStart
Many apps put a long list of Set calls in App.OnStart. Microsoft now recommends named formulas in the App.Formulas property for values like these:
gblUserEmail = User().Email;
gblIsManager = gblUserEmail = "megan.bowen@contoso.com";
gblFiscalYearStart = Date(2026, 7, 1);
Each line is Name = expression; with no Set. A named formula is always available, with no timing dependency on OnStart. It recalculates when its inputs change.
It also can’t be changed anywhere else in the app, and Power Apps calculates it only when a screen needs it, which helps load time.
The limits: a named formula can’t call behavior functions like Set, Collect or Patch, and two formulas can’t reference each other in a circle. Keep Set for values the user changes while the app runs.
Common Power Apps Variable Errors and Fixes
These are the errors I see most often in apps I review:
Incompatible type
Every formula that sets a variable must give it the same type. Set(gblCount, 0) on one button and Set(gblCount, "0") on another breaks both, even if neither button has run. Pick one type and convert with Value() or Text().
UpdateContext in App.OnStart
App.OnStart runs before any screen loads, so there’s no screen to hold a context variable. Use Set there, or set the value in the screen’s OnVisible property instead.
Same name as a collection or control
A global variable can’t share its name with an existing collection or control. A context variable can share a name with a global, but then the context variable hides it on that screen.
Reserved names
Don’t name a variable after an app property such as Width, Height, Theme, ActiveScreen or Testing. Microsoft lists these as reserved because they cause unexpected behavior.
Value is blank on another screen
If a value set with UpdateContext is blank on screen two, that’s scope, not a bug. Switch to Set or pass it with Navigate. Also remember OnStart may still be running when the first screen shows.
If you build apps like this every week, our Power Apps training course covers variables and app structure on real projects.
A few more Power Apps posts that pair well with variables:
Frequently Asked Questions
What is the difference between Set and UpdateContext in Power Apps?
Set creates or updates a global variable that every screen can read. UpdateContext creates or updates context variables that only the current screen can read. Both run only in behavior formulas such as OnSelect.
Do context variables reset when you leave a screen?
No. A context variable keeps its value until the app closes, even if the user switches screens. Reset it yourself, for example with UpdateContext in the screen’s OnHidden or OnVisible property.
Can I use UpdateContext in App.OnStart?
No. App.OnStart runs before any screen loads, so there’s no screen for a context variable. Use Set or a named formula there, or pass a value with Navigate.
Is a collection a global variable?
A collection is app-wide like a global variable, but it always holds a table and you can add, change or remove individual rows with Collect, Patch and Remove.
Where does Microsoft document Power Apps variables?
Microsoft explains all three types, plus lifetime and naming rules, in Understand variables in canvas apps.

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.