Forum Discussion

MariaPanteli's avatar
MariaPanteli
Community Member
4 years ago

Numeric Field Entry: Math Calculation

Hello Everyone, 

Reaching out as I have a little experience with Storyline, however not enough to fill in the blanks of what I'm trying to achieve. I am hoping someone can tell me if this is even possible, and if kind enough point me in the right direction. 

The Task: 

1. The learner inputs into 7 numeric entry fields to represent the number of times they complete a task each day of the week.

2. Then the 7 fields add to equal the total number of times a week they do this task.

3. Then the total number of times per week they complete the task is divided by 0.6 to provide the learner with 60% of their total number. 

What have I tried:

1. I've started out trying to keep it simple with two numeric data entry fields which add together (triggered by a button) to provide a total. (Adjust Variable - Add Figure1 to Figure 2). This all works and the calculation totals into the Figure 2 numeric field.

2. Then I used references (as taught in this video https://youtu.be/NKL1ZAROBQE) to pass the value (to keep Figure1 the same. 

However, at this point, it all goes wrong; sometimes I get a NaN error; other times I can't even explain what I've done!? After way too long staring at it and troubleshooting. I cannot work out what I'm doing wrong!

If anyone has any experience or could please provide me with any support in making this achievable; I'd be very grateful! 

Sarah

  • NedWhiteley's avatar
    NedWhiteley
    Community Member

    Hi Sarah,

    In the attached example, I have added two additional variables (TotalScore and 60PercentScore) to the seven variables generated by Storyline for the seven numeric entries (NumericEntry, NumericEntry1, . . . Numeric Entry6).

    When the user enters their daily numbers and clicks on the Calculate button the following triggers activate in order:

    TotalScore is set to equal NumericEntry
    NumericEntry1 is added to TotalScore
    NumericEntry2 is added to TotalScore
    NumericEntry3 is added to TotalScore
    NumericEntry4 is added to TotalScore
    NumericEntry5 is added to TotalScore
    NumericEntry6 is added to TotalScore
    60PercentScore is set to equal TotalScore
    60PercentScore is multiplied by 0.6
    It would also work if you just multiplied TotalScore by 0.6 at the end and didn't include the extra variable 60PercentScore, but I added the extra variable so that you can still keep the two values for TotalScore and 60PercentScore separate for use later in a later slide.

    I hope this helps, but if you have any further queries, just get back to me here.

  • MariaPanteli's avatar
    MariaPanteli
    Community Member

    Hi Ned, 

    Thank you very much for this example. I appreciate your help so much. 
    Looking at the storyline file I can see how I could have made this work.

    Thanks again.

    Kind Regards, 
    Sarah