CategoriesPower AppsPower Platform

Power Apps – Named Formulas

Today , I want to explain a really cool feature, in order to improve performance of your app and make it “code” more tidier.

NB: This is Experimental Feature, as an experimental feature, do not use named formulas in production apps.

We can use App.OnStart to inizializiate variables, load data and do some operations. These actions my be cause slow starting of your application. Sometimes we use , for example hidden button to write “reusable” code.

Now , we can write formulas and reuse it in any part of our application.

Enabled Named Formulas

Firs of all, you must enable experimental feature. Click on “Settings” and enable it:

Enabled named formulas
Enable Named formulas featur

Use it

Now, you should see new property of your app, called “Formulas”. Here you can add your formula!

Use named formulas
Formulas

Here you can add your formulas. For example:

ParamID = Param("ID");
UserEmail = User().Email;

But, of course, you can add more complex formula.

Advantages

Why we should use named formulas? let’s see some advantages:

  • The formula’s value is always available. There is no timing dependency, no event likes App.OnStart should be executed.
  • Formulas can be calculated in parallel.
  • The formula’s value is always up to date.
  • The formula’s definition is immutable. As opposed to variables, the definition in App.Formulas is the only “source of truth” and the value can’t be changed somewhere else in the app.
  • Calculated when needed. Value are calculated when app need it so this can improve app load time.

Considerations

I hope these information can help you! Here link with additional informations.

Contact me for questions! Have a nice day!

CategoriesMicrosoft 365Power AppsSharePoint Online

Power Apps – Improve performance

Hello, Today I want to explain how to improve performance of yours Canvas App. Any comments, integrations or suggestions are welcome 🙂

Cache local data

Does your data chanche during session of your app? If you reply “No”, you should store your data into local variable and get record from it, instead always ask to database.

ClearCollect(CollProject,Projects_1)

PS: Keep mind delegation problem.

ClearCollect Function more informations here.

You should also cache for user data. Example, if you you email of connected user:

User().Email

Consider:

Set(UserEmail,User().Email)

Optimize OnStart Event – Concurrent

If you create and load collection on “OnStart” event (or on visibile), consider use of Concurrent Function. People tipically write this:

ClearCollect(CollProject,Projects_1);
ClearCollect(CollManager,Manager)

In this case, formula loads each tables one at a time. If you want optimize, you should write this:

Concurrent(
ClearCollect(CollProject,Projects_1),
ClearCollect(CollManager,Manager))

Now your app fetches the tables in parallel.

Use delegations

You shouden’t retrieve all data and then filter locally. Delegate data processing to data source (If is possible). See connectors documentation to learn about delegable formula.

For SharePoint check this link.

SharePoint delegation formula

For SQL Server:

SQL Server Delefation formula
Sql Server Delegation Formula

Use Indexes Column

Simple, but people sometimes forgot to set indexes on column. For SQL Server and SharePoint, check wich columns you’re using to filter, and set Index on these columns.

How to set index on SharePoint columns.

How to set index on SQL Server and Azure SQL.

Replace Defaults() with Variable

When you want to create new record in your table you , tipically you use Default() function. When you use it, there is a call to your datasource …

Defaults(Projects_1)

And Idea is store result of this function on variable, and use it instead call Default() every time:

Set(
    newProject,
    Defaults(Projects_1)
);

Debug – Monitoring Time

If you want to understand what happens “behind the scenes”, you should start a debugging session. From Power Apps portal, select your app and click Monitor:

Monitoring…

Now you can understand durations and respons size of your function to prevent performance issue.

Considerations

Check this official link for other tips .I hope this post was usefull for you.Leave me comment if you has appreciate it.

Contact me for questions! Have a nice day!

My Agile Privacy
This website uses technical and profiling cookies. Clicking on "Accept" authorises all profiling cookies. Clicking on "Refuse" or the X will refuse all profiling cookies. By clicking on "Customise" you can select which profiling cookies to activate.
Warning: some page functionalities could not work due to your privacy choices