cancel
Showing results for
Did you mean:
Frequent Visitor

## Need solution to calculate interest rate

I am currently building a Power App to calculate loan terms.

Power Apps does not have calc. rate function. I was able to leverage a solution to calculate payment:  https://powerusers.microsoft.com/t5/Building-Power-Apps/Formula-assistance-with-PMT-excel-formula/m-...

I need to be able to calculate rate. (knowing the payment, term, and amount) To calculate the interest rate using Excel's RATE formula, you would enter =RATE(term(mths), -(pmt), amt) . The resulting interest rate will be a decimal value representing the interest rate per period. Multiplying this value by the number of periods per year will give you the annual interest rate.

Most of the feedback I am getting from the web and ChatGPT is to create a looping formula that guesses the rate.  See below.

Is there a more straight forward way to do this?

1. **Set a Trigger on Field Update**: Use the `OnChange` event of the input field where users enter data. When this field is updated, it will initiate the rate calculation process.

1. **Use a Timer Control for Iterative Guessing**: The Timer control will perform the rate guessing process in a loop-like manner. Each tick of the Timer will adjust the interest rate guess and check if it aligns with the actual payment.

1. **Control Loop with a Flag**: A flag variable will control the continuation or stopping of the loop based on whether the guessed rate's calculated payment is close enough to the actual payment.

Here's how you can structure it:

- **Input Field (OnChange Event)**

```powerapps

// Trigger the loop when the input field is updated

UpdateContext({startCalculation: true});

UpdateContext({rateGuess: InitialGuess}); // Set an initial guess for the rate

```

- **Timer Control Setup**

- Duration: Set a suitable duration for each iteration (e.g., 1000 milliseconds).

- AutoStart: Set to the `startCalculation` variable.

- Repeat: `true`, to keep the timer running for multiple iterations.

- **Timer Control (OnTimerEnd Event)**

```powerapps

If(

startCalculation,

If(

Abs(PMT5YR_CALCULATED - (LOAN_AMOUNT.Text * (rateGuess / 12) / (1 - (1 + rateGuess / 12) ^ (-TERM_MTHs_INPUT)))) <= threshold,

UpdateContext({startCalculation: false}), // Stop the timer when within threshold

UpdateContext({

rateGuess: If(

PMT5YR_CALCULATED > (LOAN_AMOUNT.Text * (rateGuess / 12) / (1 - (1 + rateGuess / 12) ^ (-TERM_MTHs_INPUT))),

rateGuess + 0.001, // Increment rate

rateGuess - 0.001  // Decrement rate

)

})

)

);

Frequent Visitor

I was able to leverage this looping method.  Most applications need to API loan terms to an external system to calculate APR and then send the value back.  This method allows you to do it within the Power App.

Announcements

#### Tuesday Tip | How to Get Community Support

It's time for another Tuesday Tip, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.       This Week: All About Community Support Whether you're a seasoned community veteran or just getting started, you may need a bit of help from time to time! If you need to share feedback with the Community Engagement team about the community or are looking for ways we can assist you with user groups, events, or something else, Community Support is the place to start.   Community Support is part of every one of our communities, accessible to all our community members.   Within each community's Community Support page, you'll find three distinct areas, each with a different focus to help you when you need support from us most. Power Apps: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pa_community_support Power Automate: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpa_community_support Power Pages: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpp_community_support Copilot Studio: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pva_community-support   Community Support Form If you need more assistance, you can reach out to the Community Team via the Community support form. Choose the type of support you require and fill in the form accordingly. We will respond to you promptly.    Thank you for being an active part of our community. Your contributions make a difference!   Best Regards, The Community Management Team

#### Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp