Variables #PowerWhat

Power Apps Canvas - Solutions

The Power Platform is an amazing application platform and is aimed at low-code and no-code individuals, while also providing the opportunity to provide additional support for those with a pro-code background. However, if you’re starting out in the industry with no-code and even a low-code background, being exposed to variables, collections, parameters, parallelism etc can be a little daunting. Have no fear, I’m here to help with this! #PowerWhat #LessCodeMorePower

Let’s look at Variables! So, we want to understand what a variable is in terms of computing. Now, if I were to put that a variable is a named unit of data that data can be assigned to, it doesn’t mean much right? Well let’s consider breaking this down with Power Automate and Power Apps.

If we had a series of characters and/or numbers (a String type) such as “PowerWhat!” and I wanted to store this information temporarily while I run a Flow to pass between steps rather than rewriting it over and over. I can assign the string to a variable such as varNewSeries.

Lets take a visual look at this below. The image shows a box that’s currently empty representing an unassigned variable. It contains no data and we assign a string to the variable using something called an operator. The operator we use in an ‘=’ this states that the variable equals the string, effectively assigning the string data to the variable. Take a look:

So, we’ve initialised a variable, we’ve used an operator to then assign(setting) a string data type to the variable. The string was “PowerWhat!”, so now whenever we use the variable ‘varNewSeries’ is will place a string of “PowerWhat!”. So how does this work in the Power Platform? Let’s take a look at Power Automate first and then Power Apps.

Power Automate

Just as the example we used before, we initialise a variable with a certain name (varNewSeries) and then we assign the variable(set) to a string of “PowerWhat!” the only ‘major’ difference here is that in the Flow we have to specify the type of variable that we are expecting, a string, at initialisation.

Power Apps

With Power Apps it becomes a little bit more ‘code-like’. As you can see from the example about we use the Set function. What this does, is allow us to initialise or select a variable such as Set(varNewSeries) then we need to pass what we’re setting to the variable in after a comma; Set(varNewSeries, “PowerWhat!”). This is similar logic to what we first displayed and then used in Power Automate. The way we do it is just slightly different, but the end result, a variable with the string “PowerWhat!’ is produced.

To reflect back on the first example with the box:

  • Set would be the operator
  • varNewSeries would be the initialisation of the variable
  • “PowerWhat!” would be the data (string) we’re going to assign


Why would I want to do something like this when I could just copy and paste it over and over? Well…

You can use variables to pass information to new screens, assign something with a variable using a button, use the variable multiple times to check something AND if the variable needed to be changed you only have to change the string in one location.

Image you’re using our string of “PowerWhat!” throughout your app as a name variable. Then your manager tells you that the 250 strings saying “PowerWhat!” in your application have to change due to the company changing the name to “FlowJoe!”. If you used a variable you can simply change it in one location, if not you will be spending a lot of time finding the string values and changing them manually.

You can watch the variable in use below, I’ve reset the variable with one button as set the variable with the code above. When the variable isn’t empty we change the text value with the variable.

Downloadable Examples

I’m looking at making this as easy as possible for people to understand. So I’ll be adding links to both the Power Automate and Power Apps examples.