Hello everyone!
Something is bothering for hours now and I can't figure out what's wrong. As wix code doesn't have the pow() function I assumed we could use " ^ " but it seems like it doesn't work...
I'm trying to make a basique tool to transform annual rates into monthly rates. Here is a piece of the code, if someone has a clue on how to do that...
//growth from year n to n+1
var Aug1
//current year's profit
var Rn
//next year's profit var Rn1
...
Rn=$w('#input6').value Rn1=$w('#input7').value
Aug1=(Rn1/Rn-1)*100
...
$w('#slider15').value=Aug1
//monthly growth needed to get the second year's profit
$w('#slider17').value= ((1+Aug1/100)^(1/12))-1
Many thanks in advance !
PS : currently for a growth of 100% in 12 months it says it's 1% per month...
Alright I figured it out, in case someone has the same issue, we just need to use ' ** ' instead of '^ '!
So many hours of my life wasted haha
Thank's Steve Cropper and abergquist for your help !
HI Steve!
I checked and all the inputs are numbers, however I tried your method and I did not work either. I tried to break down every part of the process to see where the issue is and it seems like the exponent is the problem...
I tried with the following :
Rn = 100
Rn1 = 200
// expected results: growth = 100% and monthly growth = 5.9%
A = (1 + (Aug1/100))
//expected result: 2, it's ok
B = A^(1/12) //expected result: 1.059 but the result is 2 & same result it I try with A^(0.0833333)
C = (B-1)*100
//as B doesn't work C can't work either
If you want to try yourself here is the link, it's in french but I translated the important parts in the red square so it's easier for you : https://www.qualicontent.com/calcul-d-objectifs
Hey!
First of all thank's a lot for your answer!
But it doesn't work, the result still has nothing to do with the reality...
I'm guessing it's doing integer math; does replacing the following line:
$w('#slider17').value= ((1+Aug1/100)^(1/12))-1
with the following line:
$w('#slider17').value = ((1 + parseFloat(Aug1 / 100)) ^ parseFloat(1 / 12)) - 1
make it work for you?