cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cooper01
Continued Contributor
Continued Contributor

User() function performance

I heard an offhand comment on some video a while ago about how setting User() to a variable and then referencing the variable to access properties of the User object is more performant than calling User() directly throughout a canvas app.

Does anyone know if this is true, if there's any documentation around this, and if the same pattern applies to other similar formulas? For example Today()?

2 REPLIES 2
zmansuri
Super User
Super User

No need for documentation. a variable is like a collection. It will store data locally. On other hand function will make a call every time it is written in the code. So what you are doing is making one call and save that value in variable. So performance will be faster. Also a function inside a query is not delegable and variable is. So it's a best practice to store it in a variable.

Logic is same for all the function. But, you need to make sure the value is static.

For eg. User opens App at 11:55 PM and save form on 12:01 AM.  so it will cause problems if you are using today in variable.

BCLS776
Super User
Super User


@Cooper01 wrote:

I heard an offhand comment on some video a while ago about how setting User() to a variable and then referencing the variable to access properties of the User object is more performant than calling User() directly throughout a canvas app.

Does anyone know if this is true, if there's any documentation around this, and if the same pattern applies to other similar formulas? For example Today()?


I can get behind the logic of using a variable for this if there were multiple calls to User(). However, extra variables mean extra complexity and more difficult code maintenance. There's often a tradeoff.

 

If you're looking for performance gains in an app, there are better places to examine. Look for:

  • data source operations that bring in all the columns/rows unnecessarily and then manipulate massive tables
  • connectors querying and re-querying the same data
  • poorly structured/delegated LookUp and Filter operations

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,601)