# Mortgage Formula is not working for me

**URL:** <https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525>\
**Category:** Ask for Help\
**Created:** [February 5, 2024, 6:51pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525 "2024-02-05T18:51:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 5, 2024, 6:51pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/1 "2024-02-05T18:51:21Z")

</div>

I Have Use this code here: **=PMT(17%/12,2\*12,5400)** and it is not working. Please if you would kindly direct me to success. Thank you.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [February 5, 2024, 6:59pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/2 "2024-02-05T18:59:03Z")

</div>

> [@Isaiah\_Harvey](#):
>
> =PMT(17%/12,2\*12,5400)

Have you tried an Excel column?

Or a javascript column?

```auto
function calculateMonthlyPayment(interestRate, numberOfPayments, loanAmount) {
  const monthlyInterestRate = interestRate / 12;
  const compoundFactor = Math.pow(1 + monthlyInterestRate, numberOfPayments);
  const monthlyPayment = (loanAmount * monthlyInterestRate * compoundFactor) / (compoundFactor - 1);

  return monthlyPayment;
}

const interestRate = 0.17; // 17%
const numberOfPayments = 2 * 12; // 2 years * 12 months
const loanAmount = 5400;

return calculateMonthlyPayment(interestRate, numberOfPayments, loanAmount);

```

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 5, 2024, 7:07pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/3 "2024-02-05T19:07:23Z")

</div>

Awesome, I will try this now, Thank you.

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 5, 2024, 7:16pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/4 "2024-02-05T19:16:57Z")

</div>

![Formula Error](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/1/31aa66f65f4ed9926c81e01ed0fcfc7f4bd70430.png)  
So, I used the Excel formula. This is what I used but it still didn’t not work. I do not have the option to run script or I am looking in the wrong place?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [February 5, 2024, 7:20pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/5 "2024-02-05T19:20:05Z")

</div>

I see you Loan% is a text column. It may not be seeing it as a number. I would make sure that you are passing it a number without any extra characters, such as a percent symbol. It should be a decimal, such as 0.17. You may be able to run that percent through math column first to properly convert it to a number. Or you may be able to change the column type to a numeric column, but I’m not sure what that will give you.

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 5, 2024, 7:28pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/6 "2024-02-05T19:28:32Z")

</div>

Yes, sorry I have tried both methods and they both have seem to not work.

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 5, 2024, 7:30pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/7 "2024-02-05T19:30:04Z")

</div>

I feel like I am doing something wrong but is there an working template that I can analyze and study to get a better idea to accomplish this?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [February 5, 2024, 7:44pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/8 "2024-02-05T19:44:30Z")

</div>

I don’t ever use the Excel Formula column, so I’m not sure. Maybe PMT is not supported…

You could always go with the javascript option. I’m more familiar with it and I’m pretty confident that it should work.

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 5, 2024, 7:56pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/9 "2024-02-05T19:56:14Z")

</div>

Okay Awesome, How would I accomplish this using JAVA?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [February 5, 2024, 8:07pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/10 "2024-02-05T20:07:11Z")

</div>

I posted the javascript code above. Just copy and paste it to a JavaScript column. You can set up replacement values much like you did with the Excel column, except that the replacements are P1, P2, P3 instead of A1, A2, A3.

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 5, 2024, 8:39pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/11 "2024-02-05T20:39:19Z")

</div>

Sorry for being such a pain, but this is what my attempt looks like and I am getting a NaN

 ![Java Attempt](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/d/0d9b42b788c01ee65e4cc4f0e7671372d5b6f1ef.png)

---

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [February 5, 2024, 10:11pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/12 "2024-02-05T22:11:59Z")

</div>

I think for the Excel Formula… remove the equal “🟰 “ sign

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [February 5, 2024, 11:46pm UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/13 "2024-02-05T23:46:17Z")

</div>

Can you show us the values of those p1, p2, p3 columns in your data? They should all be seen as numbers but there’s something off.

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 6, 2024, 2:05am UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/14 "2024-02-06T02:05:33Z")

</div>

Yes, that is very annoying. 😔

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 6, 2024, 2:06am UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/15 "2024-02-06T02:06:11Z")

</div>

Here is the Values:  
 ![Data Mortgage](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/5/159d9212ae3cd4c2876bf3fb571ad6bb1226866f.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [February 6, 2024, 2:06am UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/16 "2024-02-06T02:06:52Z")

</div>

I’m going to bet money that it’s the ‘yrs’ in 30.00 yrs that’s causing the issue.

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 6, 2024, 2:09am UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/17 "2024-02-06T02:09:42Z")

</div>

I didn’t think that it mattered due the “yrs” being added by the unit entry. Let me see if that is the issue.

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 6, 2024, 2:15am UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/18 "2024-02-06T02:15:43Z")

</div>

Yeah, unfortunately no change.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [February 6, 2024, 2:19am UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/19 "2024-02-06T02:19:48Z")

</div>

I modified the javascript so it should be more forgiving. Could have been other things such as commas, but I’m not sure. I tested this and it seems to be working better.

```auto
function calculateMonthlyPayment(interestRate, numberOfPayments, loanAmount) {
  const monthlyInterestRate = interestRate / 12;
  const compoundFactor = Math.pow(1 + monthlyInterestRate, numberOfPayments);
  const monthlyPayment = (loanAmount * monthlyInterestRate * compoundFactor) / (compoundFactor - 1);

  return monthlyPayment;
}

const interestRate = p1.toFixed(5); 
const numberOfPayments = p2.toFixed(5)*12;
const loanAmount = p3.toFixed(5);

return calculateMonthlyPayment(interestRate, numberOfPayments, loanAmount);

```

---

<div class="post-metadata">

**Author:** ![Isaiah\_Harvey](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/isaiah_harvey/32/70471_2.png) [@Isaiah\_Harvey](https://community.glideapps.com/u/Isaiah_Harvey)\
**Post date:** [February 6, 2024, 2:25am UTC](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525/20 "2024-02-06T02:25:15Z")

</div>

Okay Awesome!, Thank you so much!

[Next page](https://community.glideapps.com/t/mortgage-formula-is-not-working-for-me/70525.md?page=2)
