How to add calculated variables to your form?

Modified on Fri, 03 May 2024 at 06:21 PM


In this article, we are going to explain how you can add calculated variables to your form. Follow the steps provided to get started! You can also watch our interactive tutorial:




What are calculated variables?

Calculated variables are variables within your form that you can calculate, by using scores from questions. For example, if you want to calculate the BMI of a participant, you can set up a calculated variable, call it BMI_score and use the height and weight questions from the score to run your calculation. 


Calculation variables are used to set up one or multiple score for your form. For each of the calculated variables, you will be able to set the interpretation rules, that will automatically interpret a score based on a condtion. So in the BMI example, you could set a BMI_score that is higher than 25 to Overweight, and mark it red


How to add calculated variables to your form?

To add calculated variables to your form, follow the steps below:


Step 1: Turn scoring on for each question and use meaningful short names

  • Make sure that scoring is turned on for each question that you want to include in your calculated variables and set up a meaningful short name. This will make it easier to write logic later. For



Use a short and meaningful short name, turn scoring on and add scoring logic to all your questions. 


Step 2: Create a new calculated variable

  • Click on + Add new variable to start adding a new calculated variable. You will need to add the following fields:
    • Short name. Define your calculated variable so that it can be used for logic in the future. Keep it as short as possible to make logic writing easy in the future
    • Display name. This is how your name will display in the different dashboards (e.g. Participants dashboard. Make sure this name is meaningful.
    • Minimum and maximum Y axis. If your calculation has a minimum and/or a maximum score, we recommend setting these for the Y axis. In this way, your graphs in the individual record and participant dashboard will look nicer. You can decide to leave these fields empty, the graph will then dynamically decide the Y axis.
    • Calculation. Here, you can specify your calculation syntax. Currently, the following syntax is supported:
      • Scores from questions in the existing form. You can add these by the short name of the question + _score . So for example [pcl5_q2_score]
      • Basic mathematical operators. We currently support the following operators:
        • +
        • -
        • /
        • *
        • (). Example: ([pcl5_q1_score] + [pcl5_q2_score]+[pcl5_q3_score]/3) + [pcl5_q4_score]

 


Step 4: Set up your interpretation rules


Now that you've set up a calculated variable, let's add some interpretation rules. With interpretation rules, you can automatically classify a certain score with a label, and give it a colour, which will be displayed in the Records and Participants dashboard.


Some examples: 

  • In case you're calculating BMI 
    • Show the bmi_score as Underweight, if the bmi_score is below 18.5
    • Show the bmi_score as Obese, if the bmi_score is above 25
    • Show the bmi_score as Healthy, if the bmi_score is above 18.5
  • In case you want to see if somebody is meeting the DSM Criteria for PTSD, based on the PCL-5 Checklist
    • Show the pcl5_score as DSM Criteria met, if pcl5_score is greater or equal to 40.
    • Show the pcl5_score as DSM Criteria met, if pcl5_score is smaller than 40.




Example of interpretation values set up to see if a participant meets the DSM criteria. 


Once your forms have been completed, and you go to the Records or Participants Dashboard, you will be able to see the interpretation values and the raw score, within brackets. For an example, see the screenshot underneath.


Please note that the first interpretation rule that is met, will be displayed. So in the BMI example, if a participant has a bmi_score of 30, then it will be displayed as Obese and not as Healthy, since Obese is the first interpretation value that is met.


Example of how the calculated variables and their interpretation values are showing in the Records Dashboard. PHQ9 and GAD7 are both calculated variables in this case. 


Step 3: Save your form

Once you're done with your changes, save your form. Your calculated variables are now finished.


Whenever a form is submitted, the result of the calculated variable will be calculated and saved in our system, similar to question answers. A few important things to know about calculating the result:


  • The result will only be calculated when all the variables from the formula have a value. So in case a question gets skipped in the form or when a variable has been added to the formula that doesn't exist, the result won't be calculated.
  • Results are rounded off to two decimals.

Was the article missing some information or unclear? Please click on the thumbs down below and let us know how we can improve. Your feedback is always appreciated.












Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article