# Building a complex calculation in Storyline 2

I am trying to build a slide with a calculator but the formula at hand is more complex than simple addition/subtraction, etc. I hope someone in the community has had experience with something similar.

My goal is to have an effective annual rate calculator for the learner. The end result should be an interaction where the learner can put an annual percentage rate and a period (1= annual, 365 = daily) and click a button to obtain the EAR calculation.

I have two numeric entry fields, one for the APR variable and one for the Period variable. I also have a third variable for EAR as a placeholder.

This is the formula I am working with:

EAR = (1+APR/Periods) to the power of the 'periods'variable - 1.

Main questions:

1) can Articulate be set to perform this complex of a formula - i.e. raising a value to a power, multiple calculations?

2) is there a way to  convert the value of the variable to a decimal and keep it as such? I would need the APR percentage to do this for the formula to work. What I have done is set the APR value to be divided by 100 when the user clicks outside of the box; the issue I am running into is that it divides by 100 EVERY tie a user clicks anywhere outside of this box. Trying to figure out a way to lock this in on one click.

Any help is much appreciated! Thank you.

###### 3 Replies To start with, SL does complex calculations, but you have to break them into steps. In your example, you would need a series of triggers, that fire one after the other, in the correct sequence when the user initiates the action. It isn't wise to change your original variables, always use them to change temp variables. So it would look something like this;

Adjust variable Total = Apr when user clicks Calculate button

Adjust Total / Periods when user clicks, etc.

Your first problem is that it is difficult to format decimal numbers in SL (understandably, it's presentation software, not calculating or programming software).