Tutorials/Power Apps/Create Custom Power Fx Functions with Enhanced Component Properties
Power Appsintermediate

Create Custom Power Fx Functions with Enhanced Component Properties

A step-by-step guide to building a reusable PMT function using enhanced component properties, so you never have to write the same formula twice.

NA
Narmer Abader
@narmer · Published June 3, 2026

The DRY (Don’t Repeat Yourself) principle is one of the most powerful habits a developer can adopt. In Power Apps, it has historically been challenging to avoid copying complex formulas across multiple screens and apps. With the introduction of enhanced component properties, you can now build custom functions—blocks of Power Fx logic that you write once and invoke anywhere. This guide walks you through creating a practical custom function that calculates a loan’s monthly payment (PMT). The same pattern works for any repetitive calculation you want to centralize.

Original Example Scenario

Imagine your company manages several loan programs—small business loans, equipment financing, employee advances—and each app needs to compute the same monthly payment formula. Rather than rewriting (rate * principal) / (1 - (1 + rate)^-term) in every screen, you create a PMT custom function inside a reusable component. The component can be added to any app, and its function accepts the annual rate, term in months, and loan amount, returning the payment instantly.

Step 1: Enable the Experimental Feature

Custom functions rely on Enhanced component properties, an experimental feature. To turn it on:

  1. Open your app in Power Apps Studio.
  2. Go to SettingsAdvanced settings.
  3. Set Enhanced component properties to On.
Experimental Feature

Enhanced component properties are still in preview. Test thoroughly before rolling into production apps.

Step 2: Create a New Component

From the left navigation pane, switch to the Components tab and click New component. Name it something meaningful, like FinancialFunctions.

Step 3: Add a Custom Function Property

With the component selected, click New custom property in the right pane. Configure it as follows:

  • Property name: PMT
  • Property type: Output
  • Data type: Number

Click Create. Now you need to define the parameters that callers will supply.

In the custom property editor that opens, click + New parameter for each input:

ParameterData typeRequired
AnnualRateNumberYes
TermMonthsNumberYes
LoanAmountNumberYes

After creating all three, click Save.

Step 4: Write the PMT Function Logic

With the PMT property still highlighted in the component properties list, enter the following code in the formula bar. It handles a zero‑interest rate gracefully and uses the standard loan payment formula otherwise.

powerfxPMT function formula
If(
  AnnualRate = 0,
  LoanAmount / TermMonths,
  With(
      {
          monthlyRate: AnnualRate / 12
      },
      (monthlyRate * LoanAmount) / (1 - Power(1 + monthlyRate, -TermMonths))
  )
)

The With statement keeps the formula readable and avoids repeating AnnualRate / 12.

Step 5: Use the Custom Function on a Screen

Go to any screen in your app and insert the FinancialFunctions component from InsertComponents. Rename it to something short, like cmp_Fin.

Add a Label control and set its Text property to:

powerfxCalling the PMT function
cmp_Fin.PMT(0.05, 36, 15000)

Assuming a 5% annual rate, 36 months, and a $15,000 loan, the label will display approximately $449.26. You can replace the hard‑coded values with inputs from text boxes or sliders to make a fully interactive loan calculator.

Step 6: Add an Optional Parameter

To make the function more versatile, add an optional FutureValue parameter:

  1. In the PMT property editor, click + New parameter.
  2. Set Data type to Number, leave Required unchecked.
  3. Under Default value, enter 0.

Update the formula to incorporate future value (a standard extension of the PMT formula):

powerfxPMT with optional future value
If(
  AnnualRate = 0,
  (LoanAmount - FutureValue) / TermMonths,
  With(
      {
          monthlyRate: AnnualRate / 12,
          denom: 1 - Power(1 + monthlyRate, -TermMonths)
      },
      (monthlyRate * (LoanAmount - FutureValue / Power(1 + monthlyRate, TermMonths))) / denom + FutureValue * monthlyRate / Power(1 + monthlyRate, TermMonths)
  )
)

Now callers can optionally provide the amount they expect to owe at the end of the term, e.g., cmp_Fin.PMT(0.05, 36, 15000, 3000).

Performance and Delegation Considerations

  • Custom functions run entirely on the client. They do not delegate to the server, so avoid using them inside large data source filters unless the dataset is small.
  • Calculations are instantaneous for individual function calls. Looping over thousands of records to call a custom function may cause noticeable delays.
  • For operations that need to process millions of rows, prefer native delegable functions (e.g., Filter, Sum, GroupBy) written directly in the data source expression.

Common Pitfalls and Troubleshooting

MistakeSymptomFix
Enhanced component properties not enabledCustom property parameters don’t appearToggle the setting in Advanced settings
Parameter data type mismatch (e.g., passing a text string)The function returns blank or an errorEnsure callers pass numeric values, or use Value() to convert
Optional parameter without a default valueThe function fails when the parameter is omittedAlways provide a default (e.g., 0 for numbers)
Component not placed on the screenThe function name isn’t available for IntelliSenseInsert the component from the Insert pane
Division by zero (rate = 0)The function returns a long decimal errorUse the If check shown above to handle zero rate

If the label stays blank, check the formula for misspelled parameter names or missing parentheses. The built‑in formula analyzer often highlights syntax errors.

Recommendation

Start building your own library of custom functions today—even while the feature is experimental. The ability to package logic once and call it from anywhere reduces errors, speeds up development, and makes your apps easier to maintain. Share your components across projects by publishing them to a component library.

What function will you create next? A text truncation utility, a business‑day calculator, or a dynamic discount engine? The pattern shown here works for any input–output transformation.

References