IRR formula in Mendix

0
Hi everyone! I am trying to create an IRR calculation using mendix. Following is the formula. I tried implementing this formula using Create Variable in the microflow. However, it does not seem to be able to work. Is there any way to tackle this? 
asked
2 answers
0

You need to do more for a decent a approximation algorithm like interpolate the last two results and calculate the next IRR and add a treshold value (like 0.0001)

 

you can solve it by this approach:

  1. Create a non persistable entity "Cashflow" with attributes Year and Amount
  2. Create a microflow that returns as sorted list with the 0,-10000/ 1,3000 / 2, 4000 etc
  3. Create a microflow that iterates the list from 2 and uses the pow function to calculate the NPV ($Interest is 1.05 for 5%)
    $NPV + ($IteratorCashFlow/Amount div pow($Interest, $IteratorCashFlow/Year))
     return a decimal
  4. Create a approximation microflow that has 2 interest decimal variables ($IRR1, $IRR2) and
  5. $NPV1 $NVP2 (result of calling the microflow from step 3 with $IIR1 and $IIR2). Init the $IRR different, for example 5% and 50%. After calculation store $IIR2 in a temp var and change $IIR2 into
  6. $IRR1 - (($NPV1 * ($IRR2 - $IRR1)) div ($NPV2 - $NPV1))

    This is the secant method.

  7. Set $IIR1 to the temp var.

  8. Add a decision with

    abs($NPV2) < 0.001 

    if true: solved and return $IIR2 , other wise return to step 5

 

As as safetynet you can add a loopcounter for exceptions to quit the loop after 100 iterations. Increment the loopcounter.

answered
-1

Make a for-while loop and increase the IRR variable and recalculate until you got a zero result

answered