Want better performing PowerApps? Use variables.
As any developer will tell you, variables are some of the most important objects when you are creating an application, and that holds true for PowerApps as well. They help boost your overall performance when using PowerApps.
One thing I’ve learned about PowerApps (in particular when designing them), is that the more screens you have, the slower editing an App can be. This is just one example of where a global variable can help!
Using Variables
For example, let’s say I have three forms I want to add to a PowerApp. My goal is to have a user access a particular form by pressing a button from the home screen. By default, you may create four different screens – one for home, and three more to house each form.
But with a variable, we can actually hide or display each form on a single screen by setting it when the button is selected.
So, try this: Create a ‘Home Screen’, then Create a ‘Forms’ screen. On the ‘Home Screen’, add three buttons.
For my example, my form names will be Form1, Form2, and Form3. On each button’s ‘OnSelect Property’, set it to:
Set(formVar, “Form1vis”); Navigate(Forms, Cover)
Change Form1vis to Form2vis and Form3vis for each button.
Now on the ‘Forms’ screen, add all three forms, and set the ‘Visible Property’ for ‘Form1’ to the following:
Switch(formVar, “Form1vis”, true, false)
Repeat this for Form2 and Form3, replacing Form1vis with Form2vis, or Form3vis.
Now, test your app from the home screen. You will find that every time you click the button, the corresponding form will be the only one displayed!
Final Thoughts
This is just one small example of how variables can make your PowerApps more dynamic, and better performing.
Part five of a series.