Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

Power Apps Set Function: Text, Numbers, Booleans, Records and Blank Values

A button often needs to remember something after the click: a name, a count or a yes/no flag. Power Apps has no Dim or var statement, so where does that value live?

In this tutorial, we’ll use the power apps set function to store text, a click counter, a boolean, a record and a table in global variables, and then reset them to blank without the surprises we hit in testing.

Quick answer: put Set(variableName, value) in a behavior property such as a button’s OnSelect. Power Apps creates the global variable the first time it sees it, every screen can read it, and Set(variableName, Blank()) clears it.

Set(varName, txtStName.Text)

What You Need Before You Start

  • A Microsoft 365 account that can create canvas apps in Power Apps.
  • Basic Studio skills help. Our guide to creating a canvas app from a SharePoint list covers the first build in depth.
  • A SharePoint list to read from. We use Service Requests, a help desk list with 623 items.
  • About 15 minutes. Every result below comes from our Service Desk Demo app, tested in Preview on 11/01/2026.

Step 1: Build the Demo App and the Set() Screen

If you’ve never built a canvas app, follow these steps once. A canvas app is one where you place every control yourself.

Here’s the list we connect to. Each item has a Title, Status, Priority, Requester and DueDate.

Service Requests SharePoint list with Title, Status, Priority and DueDate columns

1. Start a new app. Go to make.powerapps.com and select Start with design on the Home page.

Power Apps maker portal Home page with the Start with design option

2. Create a blank canvas app. Select Create from blank.

Create from blank option for a new Power Apps canvas app

3. Pick the Tablet layout. Choose Tablet and select Create. Power Apps Studio, the app editor, opens.

Start with a blank canvas dialog with the Tablet layout selected

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

Add data pane in Power Apps Studio with the SharePoint connector

5. Connect to the site. Paste your SharePoint site URL and select Connect.

Connect to a SharePoint site dialog with the site URL box

6. Choose the list. Check Service Requests and select Connect. The list is now a data source, which simply means a place the app reads records from.

Choose a list dialog with the Service Requests list checked

7. Add the demo screen. Select New screen > Blank. To rename it, select the screen and click its name in the Properties pane. We called it scrSetDemo.

8. Insert the controls. From the Insert menu, add a Text input named txtStName, eight buttons and one label per variable. Each label’s Text property shows a variable, like varClicks.

To set a property, select the control, pick the property in the dropdown on the left of the fx formula bar, then type the formula. Run the app with Play at the top right, or hold Alt and click a button. Press Ctrl+S to save.

Here’s the screen in Preview before any button runs. Notice that every variable already exists, and every one of them is blank.

Set demo screen in Preview where every global variable is still blank before any button runs

Learn confirms this: all variables start blank when the app opens. A blank Boolean label displays false, though, which matters later in Step 6.

Step 2: Store Text From a Text Input

Select the Set varName button, pick OnSelect and type the formula below. OnSelect is a behavior property, so it runs actions when the user clicks. Our post on the Power Apps button OnSelect property lists the others.

Set(varName, txtStName.Text)

The label next to varName shows the value plus an IsBlank test, so we can see what Power Apps really stored:

varName & "   (IsBlank: " & IsBlank(varName) & ")"

In Preview, I typed Bijay and clicked the button. The label changed to Bijay (IsBlank: false). The variable keeps that text even if you clear the text input afterward, because Set copies the value at click time.

Step 3: Count Clicks With a Number Variable

Same screen, Count +1 button. A variable can read its own value inside Set, which turns it into a counter:

Set(varClicks, varClicks + 1)

You don’t have to start it at 0. On the first click, varClicks is blank, and blank + 1 returns 1. Three clicks later, the label showed 3.

Note: to reset the counter, give another button Set(varClicks, 0). The value also resets when the app closes, since a global variable only lives while the app runs.

Step 4: Set a Boolean Variable (true, Toggle, or From a Condition)

A boolean variable holds true or false. It’s the usual way to show or hide a panel, flag an admin or remember a choice. We tested three ways to set one.

Set it to true or false

The varIsAdmin = true button uses the simplest form. Type true or false without quotes, or Power Apps stores text instead of a boolean.

Set(varIsAdmin, true)

Toggle it with the ! operator

The Toggle help button flips the value each time. The ! means Not, so true becomes false and false becomes true:

Set(varShowHelp, !varShowHelp)
OnSelect property of the Toggle help button with Set varShowHelp to not varShowHelp

We then set the help label’s Visible property to varShowHelp. It’s the same pattern as making a control visible when a checkbox is checked, just driven by a button.

Here’s Preview after Steps 2-4: varName holds Bijay, varClicks is 3, varShowHelp is true and the blue help line appeared.

Preview showing varName Bijay, varClicks 3, varShowHelp true and the visible help label

Set it from a condition

Any formula that returns true or false works as the value. This one checks whether ticket ID 2 is past its due date, using Today() in Power Apps:

Set(varIsLate, LookUp('Service Requests', ID = 2).DueDate < Today())
OnSelect formula that sets varIsLate from a LookUp DueDate compared with Today

In Preview, varIsLate changed from false to true. The comparison runs once, at click time. If the due date changes later, varIsLate won’t update until Set runs again. When you only need the live answer, put the condition straight in an If statement instead.

Step 5: Store a Record and a Table

A global variable can also hold a whole record (one list item) or a table (several items). The Record button stores ticket ID 2 with the LookUp function:

Set(varReq, LookUp('Service Requests', ID = 2))

The Table button stores the first three tickets:

Set(varTop3, FirstN('Service Requests', 3))

We read one field of the record with dot notation, and wrapped it in Coalesce so the label says (blank) when nothing is stored:

Coalesce(varReq.Title, "(blank)")

After both clicks, varReq.Title showed Password reset #1005 and CountRows(varTop3) showed 3. varIsAdmin and varIsLate both read true by then.

Preview with varIsAdmin true, varIsLate true, varReq Title Password reset 1005 and CountRows 3

Note: Set always replaces the whole table. To add or remove rows one at a time, use a collection instead, as in our guide to adding items to a Power Apps collection.

Step 6: Set a Variable to Blank

Microsoft’s answer is short: to clear a variable, set it to Blank(). The Set all to Blank() button clears three variables of different types at once. A semicolon separates the actions:

Set(varName, Blank());
Set(varIsAdmin, Blank());
Set(varReq, Blank())
Expanded formula bar with three Set calls that reset varName, varIsAdmin and varReq to Blank

After the click, varName went blank, varReq.Title showed (blank) and the other four variables kept their values. Only the variables you name are cleared.

Preview after Set all to Blank where varName and varReq are blank and varIsAdmin shows false

The blank Boolean that still says false

Look at varIsAdmin. It displays false, yet IsBlank(varIsAdmin) is true. A blank Boolean reads as false in text and in If(), so you can’t tell “never answered” from “answered no” by its display. This is the label we used to catch it:

varIsAdmin & "   (IsBlank: " & IsBlank(varIsAdmin) & ")"

If the difference matters (an unanswered yes/no question, say), test it with IsBlank() before you test the value. The same idea helps when you set a dropdown default value to blank.

Set(x, Blank()) vs Set(x, “”)

We also tried the empty-text version on the varName = empty text button:

Set(varName, "")

IsBlank(varName) returned true here too, because IsBlank treats an empty string as blank. For text, either works. Blank() fits every type, though, while “” is text and only suits text variables.

Preview after setting varName to empty text where IsBlank returns true

Check it in the Variables pane

Select Variables ({x}) on the left authoring menu and expand Global variables. I searched for “varIs”: varIsAdmin shows Boolean: Blank while varIsLate shows Boolean: true.

Power Apps Variables pane listing varIsAdmin as Boolean Blank and varIsLate as Boolean true

That pane is the fastest way to see what a variable really holds, and where it’s set or used, without adding labels.

Set() Cheat Sheet: What We Tested

GoalFormulaResult in our app
Text from an inputSet(varName, txtStName.Text)Bijay (IsBlank: false)
CounterSet(varClicks, varClicks + 1)3 after three clicks (blank + 1 = 1)
BooleanSet(varIsAdmin, true)true
Toggle a booleanSet(varShowHelp, !varShowHelp)false to true, help label shows
Boolean from a conditionSet(varIsLate, ...DueDate < Today())true for ticket ID 2
RecordSet(varReq, LookUp(...))Password reset #1005
TableSet(varTop3, FirstN(...))CountRows = 3
Clear any typeSet(varIsAdmin, Blank())Displays false, IsBlank = true
Clear textSet(varName, "")IsBlank = true

Should You Use Set() or UpdateContext()?

Set() creates a global variable that every screen can read. UpdateContext() creates a context variable that lives on one screen. We compare both, plus collections, in global vs context variables in Power Apps.

Our rule: use Set() when another screen needs the value, and UpdateContext() for screen-only state like a popup flag. Need several values in one click? See how to set multiple variables at once.

Common Mistakes to Avoid

  • Using Set() in a Text or Visible property. Set only works in behavior formulas like OnSelect. Put the variable in Text, and Set in a button.
  • Changing a variable’s type. Learn says a second Set(X, "Hello") after Set(X, 1) is an error: every Set for one variable must use the same type.
  • Expecting the variable to refresh. Set stores a snapshot. Run Set again after the data changes.
  • Trusting a Boolean that shows false. It may be blank, as Step 6 showed. Check IsBlank() first.
  • Reusing a control or collection name. A global variable can’t share one. A var prefix avoids it, and you can rename variables in Power Apps later.

Next Steps

Once a record sits in a variable, the next skill is changing one field of it. Microsoft’s example pairs Set with Patch, so our Power Apps Patch function guide is the natural next read. For more, browse the Power Apps tutorials hub.

We’d read these next if you’re working with variables and data:

Frequently Asked Questions

How do I set a boolean variable in Power Apps?

Use Set(varIsAdmin, true) or Set(varIsAdmin, false) in a behavior property such as OnSelect, without quotes. To flip it, use Set(varShowHelp, !varShowHelp). You can also store any condition, like Set(varIsLate, LookUp(‘Service Requests’, ID = 2).DueDate < Today()).

How do I set a variable to blank in Power Apps?

Use Set(varName, Blank()). It works for text, numbers, booleans, records and tables. For text, Set(varName, “”) also makes IsBlank(varName) return true.

Why does my blank Boolean variable show false?

A blank Boolean displays false in a label and acts like false in If(). IsBlank() still returns true, and the Variables pane shows Boolean: Blank. Test IsBlank() first when blank and false mean different things.

Where can I use the Set function in Power Apps?

Only in behavior formulas, such as a button’s OnSelect, a control’s OnChange, a screen’s OnVisible or App.OnStart. Set has no return value. See Microsoft’s Set function reference.

Is a Set() variable available on every screen?

Yes. Set creates a global variable with app scope, and it keeps its value until the app closes. For a screen-only variable, use UpdateContext. Microsoft explains all three types in Understand variables in canvas apps.