All Collections
Tutorials
Templates & Surveys
How to use math in conditional logic surveys
How to use math in conditional logic surveys

A tutorial showing how you can add math to your conditional logic when making templates for your surveys

Sam avatar
Written by Sam
Updated over a week ago

Note: Before we get started, take a moment to familiarize yourself with our tutorial on setting up templates with conditional logic found here


In This Tutorial Youʻll Learn:


STEPS

Simple Math

1) Add some integer or decimal questions that you want to use for a calculation

2) Add the question that you want to use to show the final number

3) Click the Conditional Logic tab then click Add Rule

4) Fill in the Results field with the equation

*If you need help click the (?) to show hints

5) Hit Save, then test your survey to make sure it's working correctly


Math Including Specific Numbers

Let's begin by setting up a sample template to convert Celsius to Fahrenheit. The equation that we need to set up looks like this: C x 1.8 + 32 = F.

1) Our first question will be where we input the temperature in celsius. To do that simply add a question, add a label, set the type to be decimal, leave the default value blank.

2) Next we need to add a question that will show the result we are expecting. Add a Question, set type to Decimal, then click the Conditional Logic tab to set up your expression

5) Click Add Rule, then click within the Result field to see a dropdown list that will let you arrange your expression with all the integer/decimal type questions within your template. For the numbers, you can begin typing then press Create to make a number "button".

Note: You can click the question mark icon by Result to see sample equations

6) Save your template and head over to its dedicated survey to test it out! If you followed this tutorial correctly, you should see the math doing its work. For example, I entered 27º in our celsius input box and was returned 80.6º in fahrenheit.


Repeating Sections: Sums and Averages

You can use the math features to sum and average repeating section number totals.

For this tutorial we will use the example of creating a work hours log to enter individual hours worked by staff on a specific day.

1) Add a Section then set the Repeating limit

  • Example: A section called "Work Hours" that repeats 10 times

2) Add a integer or decimal type question within the section

  • For our example we added "Hours" as a decimal type question

3) Add another section, then add questions that require math

  • For our example we created "Totals" as the new section and added two questions that will use the entires from "Work Hours" to do math

Section Total: SUM

Now that we have our sections and questions set up...

1) Add conditional logic to the questions that is asking for a sum

  • For example, Total Hours needs to add all "Hours" entries together

  • To get a sum, the expression in Results is SECTIONSSUM ( Hours )

Section Total: AVERAGE

1) Add conditional logic to the questions that is asking for an average

  • For example, Average Hours is asking for the average of all the "Hours" entries

  • To get an average, the expression in Results is SECTIONSAVG ( Hours )

2) SAVE the form

Test your math!

1) Go to your survey and add a new entry

2) Enter multiple entires in your repeating section to see the math in action

  • In our example, "Total Hours" and "Average Hours" automatically update as you add entries to the repeating section

Did this answer your question?