Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
1 like 0 dislike
598 views
in Videos by 65 73 123

As low-code solutions grow in size and complexity, performance and maintainability become just as important as speed of delivery. In modern Power Apps canvas apps, Named Formulas and User-Defined Functions (UDFs) have emerged as essential tools for building scalable, high-performing applications.

By moving away from heavy logic in App.OnStart and adopting these newer patterns, developers can significantly reduce app load times, simplify maintenance, and create more predictable, robust solutions.


🎥 Watch the Session: Named Formulas & UDFs in Power Apps

This session demonstrates real-world performance improvements and best practices for using Named Formulas and User-Defined Functions effectively.


A Centralized Source of Truth

One of the greatest strengths of Named Formulas is that they enforce a single source of truth.

Unlike variables which can be initialized or modified from multiple places Named Formulas are defined only once, in a centralized location:
App.Formulas

This approach delivers immediate benefits:

  • Improved readability
  • Easier troubleshooting
  • Faster updates when business logic changes

If a requirement changes, developers update the formula in one place and the change automatically applies across the entire app.


Moving Beyond App.OnStart

Historically, developers relied heavily on App.OnStart to:

  • Initialize global variables
  • Preload data
  • Configure app behavior

The downside?
All logic in App.OnStart runs sequentially, before the user sees the first screen often resulting in slow startup times and poor user experience.

Why Named Formulas Are Better

Named Formulas solve these problems by design:

  • No timing dependency
    They don’t execute in sequence. They’re evaluated only when needed.

  • Lower memory footprint
    Unlike global variables, they don’t permanently occupy memory once referenced.

  • Immutable by design
    Their values cannot be overridden by actions elsewhere in the app, preventing accidental logic corruption.

The result is a faster, safer, and more predictable app lifecycle.


Named Formulas vs. Global Variables

Although they may seem similar, the Power Apps engine treats them very differently.

Feature Global Variables Named Formulas
Declaration Anywhere (OnSelect, OnVisible) Centralized in App.Formulas
Can be updated Yes (Set) No (Immutable)
Initialization Must be explicitly triggered Automatic when referenced
Execution model Sequential Smart / non-ordered

A key advantage is dependency awareness.

If Formula A depends on Formula B, Power Apps automatically resolves the dependency regardless of the order in which the formulas are written as long as no circular reference exists.


Anatomy and Implementation Best Practices

To ensure clarity and teamwork, a clear naming convention is strongly recommended.

Naming Convention

Use a prefix such as:

  • NF_ → Named Formula

This instantly signals that the value is centralized and immutable.

Syntax Rules

Each formula must follow this pattern:

FormulaName = Logic;

⚠️ The semicolon is mandatory.
Missing it causes errors across all formulas in the property.

Supported Data Types

Named Formulas are extremely versatile and can store:

  • Booleans, numbers, and strings
  • Tables and objects (e.g., hardcoded menus or navigation structures)
  • Images
  • Power Fx logic (e.g., responsive font sizes based on screen width)

User-Defined Functions (UDFs)

For more advanced reuse scenarios, User-Defined Functions can be enabled from the app settings.

UDFs allow developers to:

  • Accept parameters
  • Apply complex logic
  • Return a calculated result

Real-World Example

Calculating an exact duration between two dates in Power Apps can be frustrating, as built-in functions often round values.

A UDF can:

  • Handle minutes, hours, and days accurately
  • Validate inputs
  • Be reused consistently across the app

Define it once, use it everywhere.


Important UDF Considerations

While powerful, UDFs come with constraints developers must plan for:

  • No data writes
    Functions like Patch are not supported inside UDFs.

  • Manual error handling
    Developers must explicitly handle:

    • Blank inputs

    • Invalid date ranges

    • Logical inconsistencies

When used correctly, UDFs dramatically improve clarity and consistency.


Key Takeaways for Power Apps Developers

By embracing Named Formulas and UDFs, teams gain:

  • Faster app startup times
  • Cleaner, more readable logic
  • Easier long-term maintenance
  • Reduced risk of accidental overrides

These tools encourage a declarative mindset define intent once, let the platform handle execution.


Analogy: Making It Click

Think of global variables like carrying items in your pockets.
The more you carry, the heavier and slower you become.

Named Formulas, on the other hand, are like a vending machine in the hallway:

  • Nothing weighs you down
  • Everything is instantly available
  • You only get what you need, when you need it

That’s the difference between loading everything upfront and letting the platform work intelligently.


🌍 Continuing the Journey

This bootcamp 2025 may have ended, but our community journey continues.

🔗 Stay Connected


If you don’t ask, the answer is always NO!
...