Marcel Lehmann

learn and find tipps & tricks around the powerplatform

The Big 5 (Variables / Parameters) in PowerApps

Photo by Ann H on

If you create a PowerApp and look around on the internet for solutions, you will come across the following functions from time to time.

  1. Set()
  2. updateContext({})
  3. with()
  4. navigate(…,…,PARAMETER)
  5. param()
  6. Addition: If you want, you can also add a collection (Collect, ClearCollect).

In the following, I will show you briefly what I use them for and why you should think about using them too.

  1. set() function
    This is probably the best known function of all. It sets the value of a global variable. Global variables are useful when you want to store a value and use it on different screens. This can be used in the OnStart, where you set style variables, the logged in user or if you select an element from a gallery and want to use this element somewhere else.


  1. updateContext({})
    This is the little brother of the Set function. Sets the value of one or more context variables of the current screen. I mainly use this when I want to change a value (true,false) to show/hide something, for example. Mostly a pop-up or another input window.

    Here I set the variable “locPopUp” first to “true” and then again to “false”.

UpdateContext({locPopUp: true});
UpdateContext({locPopUp: false})

  1. with({})-function
    This function I discovered some time ago and is again the little brother of UpdateContext. Here “variables” are stored exclusively for a function and can only be referenced in this function. I use this mainly within functions, as soon as I have to use a certain function several times.

    In this example, I write the variable “locText”, to which I then reference 2x in the further course of the function. Important: the With function is closed only at the end of all functions.

{locText: TextInput1.Text},

  1. navigate(…,…,{PARAMETER})
    This parameter was unknown to me for a long time, because I usually stopped after the first comma and closed the parenthesis. But if you put two more commas after the Navigate, you can pass one or more parameters to the screen you want to navigate by using the curly braces. This parameter is then only available on the following screen. (unless you write it into another variable or pass this value again)

    In this example, I pass to Screen1 the parameter “locVariableNextScreen” with the text “Yes we can use it”.

{locVariableNextScreen: “Yes we can use it”}

  1. param()
    This provides access to parameters passed to the app when the user has it open. This parameter is usually used less often, as this is exclusively appended to the app’s URL. Thus it is possible to navigate the user to a certain page or to pass certain values to the app.

    Here, I pass the parameter “Admin” with the value “true” in the URL. In OnStart I then set the global variable “varAdmin” with the parameter “true”. So I can enable additional settings for an admin, using this parameter. (Visible: varAdmin)


Extra tip: If you use a variable and want to use it as a boolean, which is always the opposite of the current state, use the “!” in front of the variable. This reverses the value.

This example reverses the value every time it is executed. If is currently true, it will be changed to false and vice versa.

UpdateContext({locPopUp: !locPopUp})

Published by

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: