Power Community

Power Community

Unlocking the Power of Named Formulas in Power Apps

Named Formulas allow you to create your own reusable properties within your app. Imagine defining custom calculations like a pro mathematician, but without the headache.  These formulas streamline initialization and enhance app performance. 

Advantages of Named Formulas:

  1. Simplicity: Say goodbye to spaghetti code. Named Formulas declutter your app’s initialization process.
  2. Speed: Reduce app load time by leveraging pre-calculated values.
  3. Reuse: Create your own points of reuse—like having superpowers for your app logic.
  4. Maintainability: Update formulas in one central location without breaking a sweat.

Ready to level up your app performance? Dive into the world of Named Formulas!

In my use case I have a financial statement to display through a gallery. 

ClearCollect(
    FinancialStatements,
    {Date: "2024-01-01", AccountName: "Sales Revenue", Debit: 0, Credit: 150000, Balance: 150000},
    {Date: "2024-01-02", AccountName: "Service Revenue", Debit: 0, Credit: 50000, Balance: 200000},
    {Date: "2024-01-03", AccountName: "Interest Expense", Debit: 5000, Credit: 0, Balance: 195000},
    {Date: "2024-01-04", AccountName: "Rent Expense", Debit: 20000, Credit: 0, Balance: 175000},
    {Date: "2024-01-05", AccountName: "Utilities Expense", Debit: 3000, Credit: 0, Balance: 172000},
    {Date: "2024-01-06", AccountName: "Inventory", Debit: 25000, Credit: 0, Balance: 147000},
    {Date: "2024-01-07", AccountName: "Accounts Payable", Debit: 0, Credit: 15000, Balance: 162000},
    {Date: "2024-01-08", AccountName: "Loan Payment", Debit: 10000, Credit: 0, Balance: 152000},
    {Date: "2024-01-09", AccountName: "Office Supplies", Debit: 2000, Credit: 0, Balance: 150000},
    {Date: "2024-01-10", AccountName: "Miscellaneous Income", Debit: 0, Credit: 3000, Balance: 153000}
)

One of the requirements to show the Totals of Debit, Credit and Balance.

What you can achieve with the Named Formulas is the following.

Go to App > Formulas property and enter the following code:

nfDebitTotal = Sum(FinancialStatements, Debit);
nfCreditTotal = Sum(FinancialStatements, Credit);
nfDebitCreditTotal = nfDebitTotal - nfCreditTotal;
nfBalanceTotal = Sum(FinancialStatements, Balance);

Now I can use the Named Formula everywhere in my app.

If I have to edit the formula (e.g. change the Sum to Max) I just do this one place and it is changed for every control I used this formula. 

SpongYe_0-1712871334522.png

(in my example the financial statement value doesn’t change and is only uploaded 1x time)

You can also use the Named Formula also for locking information of the current user and filtering your dataset etcc.

Remember, named formulas are especially valuable when data doesn’t need to be modified after being set.

Feel free to let me know if you found this topic useful.

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Preferred Solution | New feature | Microsoft Dataverse

Click on the below image to navigate to my YouTube Channel. Please like and share your valuable feedback on this...

More Articles Like This

- Advertisement -spot_img