Unlock Efficiency with Power Apps Named Formulas

Power Apps offers several ways to manage and reuse values, including variables, collections, and context variables. However, modern Canvas Apps now boast a powerful feature called Named Formulas, allowing developers to define reusable logic in a centralized location. This enhancement significantly reduces code duplication, improves readability, increases maintainability, and optimizes application performance. Unlike traditional variables, named formulas automatically recalculate when their dependencies change, much like familiar Excel formulas.

What are Named Formulas?

Named Formulas are reusable expressions defined within the App.Formulas property of a Canvas App. Instead of repeating the same formula across multiple controls, you define it once and reference it throughout your application.

For example, instead of writing:

ColorValue("#005A9C")

on multiple controls, you can define a named formula.

Why Use Named Formulas?

Consider the difference in maintenance:

Without Named Formulas:

Label1.Fill = ColorValue("#005A9C")
Label2.Fill = ColorValue("#005A9C")
Label3.Fill = ColorValue("#005A9C")

If the color needs to change, you must update every single formula. This is tedious and error-prone.

With Named Formula:

First, define the named formula:

PrimaryColor = ColorValue("#005A9C")

Then, all controls can reference it:

Label1.Fill = PrimaryColor

Now, if the color needs to change, only one update to the PrimaryColor named formula is required, propagating the change instantly across the app.

Benefits of Named Formulas

How Named Formulas Work

The workflow is straightforward:

  1. Define a Named Formula within App.Formulas.
  2. Reference this Named Formula across your app.
  3. Power Fx automatically recalculates the formula when its dependencies change.

Unlike variables that often require explicit updates using Set(), named formulas automatically update based on data changes.

Enable Named Formulas

To start using this feature, navigate to:

SettingsUpcoming featuresExperimental featuresNamed Formulas.

Ensure the feature is enabled in your environment.

Creating Your First Named Formula

Open your Canvas App, navigate to the App object, and select the Formulas property. Here, you can create your first named formula:

PrimaryColor = ColorValue("#005A9C")

Save your application after defining the formula.

Using a Named Formula

Any control within your app can now reference the named formula. For instance:

Label1.Fill = PrimaryColor

This will apply the defined blue background to the label.

Example 1: Application Theme Color

Define your theme colors:

App.Formulas:
PrimaryColor = ColorValue("#005A9C");
SecondaryColor = ColorValue("#0078D4");

Use them in your controls:

Button1.Fill = PrimaryColor
Label1.Color = SecondaryColor

This ensures consistent application branding.

Example 2: Current User Information

Simplify user data retrieval:

CurrentUser = User()

Then use it like this:

Label1.Text = CurrentUser.FullName

Instead of repeatedly calling User(), you use a single, reusable formula.

Example 3: Company Information

Centralize company-specific details:

App.Formulas:
CompanyName = "CRMONCE"
SupportEmail = "support@crmonce.com"

Reference them easily:

LabelCompany.Text = CompanyName
LabelSupport.Text = SupportEmail

This allows for centralized configuration management.

Example 4: Environment Variables

Manage environment-specific settings:

BaseUrl = "https://api.crmonce.com"

Use it in actions:

Launch(BaseUrl & "/dashboard")

Changing the URL requires only one update in App.Formulas.

Example 5: Data Source Filtering

Centralize complex filtering logic:

ActiveAccounts = Filter(
 Accounts,
 Status = "Active"
)

Apply the filter to a gallery:

Gallery1.Items = ActiveAccounts

This greatly improves readability and centralizes filtering logic.

Named Formulas vs. Variables

Feature Named Formula Variable
Automatic Recalculation Yes No
Reusable Yes Yes
Requires Set() No Yes
App Startup Dependency No Often
Performance Better Depends
Maintenance Easier Moderate

Named formulas automatically recalculate based on dependencies, whereas variables generally require explicit updates, making named formulas more efficient for read-only derived values.

Named Formula Example for App Settings

Consolidate application metadata:

App.Formulas:
AppVersion = "1.0.0"
AppTitle = "CRMONCE Portal"
DefaultLanguage = "English"

Use these in labels:

LabelVersion.Text = AppVersion
LabelTitle.Text = AppTitle

Performance Advantages

Traditional Apps:

App.OnStart
  → Multiple Set()
  → Initialize Variables
  → Load App

With Named Formulas:

App.Formulas
  → Automatic Evaluation
  → Optimized Calculation
  → Load App Faster

Microsoft recommends using App.Formulas and named formulas to improve app startup performance and allow Power Fx to optimize formula evaluations.

Best Practices

Common Use Cases

Real-World Example: Employee Portal

Consider an employee portal:

App.Formulas:
CurrentUser = User();
CurrentYear = Year(Today());
CompanyName = "CRMONCE";

Usage:

WelcomeLabel.Text = "Welcome " & CurrentUser.FullName
Footer.Text = CompanyName & " - " & CurrentUser.Department & " - " & CurrentYear

This approach leads to:

Conclusion

Named Formulas represent one of the most valuable enhancements in modern Power Apps development. By defining reusable expressions within App.Formulas, developers can drastically reduce duplicate code, improve application performance, simplify maintenance, and create cleaner, more robust Canvas Apps. Whether you are managing application themes, user information, environment settings, filters, or complex business calculations, Named Formulas offer a scalable and efficient approach that aligns perfectly with Power Fx's declarative programming model.