Improve Powerapps Performance

The performance of an app plays a pivotal role in determining its success, as a slow-loading application can significantly impact user satisfaction and lead to heightened frustration among users. Ensuring optimal app performance is crucial for delivering a seamless and enjoyable user experience.

1. OnStart versus OnVisible The OnStart is an App object property. Formulas written on the OnStart are run only once, when the app starts, and never again in the same session of the app. All the formulas written on this property must complete its execution before the app opens. This is often used to initialize data that we will need throughout the app, only execute the code once in the app and never again.

The OnVisible is a screen property. Formulas in this property are run every time a user navigates to that screen. The screen will render before the formula is finished processing. The formulas written on this property of the screen will execute every time a screen is shown.

2. First with Filter Vs LookUp When we use the First function with Filter and the LookUp function described below, both gives the same result. But let us see which is performance optimized.

Power Apps Formula

First(Filter(‘My Students’, Name= “Ashish”))

The Filter function scans the entire datasource and returns the table of records which satisfies the given conditions, and then by using the First function we are extracting the first record from the table.

Power Apps Formula

LookUp(‘My Students’, Name= “Ashish”)

Whereas the LookUp functions scan the data source until it gets the first match. So, as compared between these two we need to use LookUp function to optimize the app for such use cases where we want only one record.

3. User variable to store the formula results We can use the variables (Global variables, context variables, or collections) to store the formula results, and use those variables in the app, which reduces the formula execution calls again and again.

Example: a) Set(varUser, User())
b) Collect(Filter(‘My Students’, Name= “Ashish”))

Note: The Collect function is not delegable. By default, that means only the first 500 items will be returned from the data source and stored in the collection.

4. Concurrent function in Power Apps The Concurrent function evaluates multiple formulas concurrently with one another.

Normally, multiple formulas are evaluated by chaining them together with the ; (semi-colon) operator, which evaluates each formula sequentially means one after the other.

Power Apps Formula

Formula1; Formula2; Formula3

With the Concurrent function, the app will evaluate all formulas concurrently, this concurrency will help users wait less for the same result.

Power Apps Syntax Concurrent( Formula1, Formula2 [, ...] )
• Formula(s) – Required. Formulas to evaluate concurrently. You must supply at least two formulas.

5. Use Components in Power apps It is recommended that an app does not contain more than 500 controls in one app. In order to reduce that we can use the components in the canvas apps.

6. Reduce Assets Size Reduce the file size of the image used in the app to optimized the performance because large size delay in loading.

7. Control Dependency

If one control property is referenced on another screen, then both the screen will be loaded in the memory. This could lead to chaining and reduces the app performance.

For example: a) One screen has a Label1. And on another screen, we are using the Label1 color property by using the formula Label1.Color, when one screen loads, both screens are loaded by the powerapp, which reduces the performance.

To encounter such an issue, use the variables. For example, Set(varColor, Label1.Color) and set this variable on the another screen label Color property value as varColor.

b) Sometimes we are using a Gallery control and a Form control, when a record is selected in a gallery it is referenced on another screen in the form control by using GalleryName.Selected. If we do so then both screens are loaded by the power app, which reduces the performance.

Again, we can use variables, set the following formula on the OnSelect property of the gallery control.

Power Apps Formula

Set(varSelected, GalleryName.Selected); Navigate(Screen2)

And use the varSelected variable on the Item property of the Form control.

8. Too many refreshes

The Refresh function forces the power apps to retrieve a fresh copy of datasource in power apps.

Sometimes Power Apps will automatically refresh the datasource. For example, when we use a Form control to submit a new record to a data source, powerapps will automatically refresh our datasource. We can see this with using a Gallery control to display those records. If we include a Refresh function when we navigate to the Gallery screen, we are now refreshing the data that Power Apps already refreshed. This is redundant and slows down our app for no reason.

But when there are several users usings the app and adding the data that time the gallery is not updated with the data source records created by others. To update the gallery with the data source, we have to force the powerapp to refresh the datasource in order to see the fresh copy of datasource.

To force the power apps to do so, we can use the following powerapps formula.

Power Apps Formula

Refresh(Name_of_the_DataSource)

Here, Name_of_the_DataSource is the required parameter which specifies the data source that we want to refresh.