All Collections
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. If you are already familiar with it let's proceed!

In This Tutorial Youʻll Learn:

Setting up math is pretty easy

First add some decimal or numeric questions that you want to use for a calculation

Then add the question that you want to use to show the final number

Click add expression and fill in the result field with the equation

If you need help click the "?" to show the hints

Here is a more complicated example using a hidden field to calculate a value

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, and set the type to be decimal and leave the default value blank. Don't forget to give it a label!

2.) Next we need to add our two number values that will be used in our equation. Same process as step 1 but this time we set our default values to be the numbers used in our equation.

3.) For neatness purposes, we're going to make these values invisible in our forum since they will not change and to do that, simply scroll down to the question's display settings and uncheck Show in form.

4.) The final step is to create a question that will show us our result. This step is very crucial to follow correctly otherwise your math will not work. After selecting the integer question type you will click the Add Rule button which will allow you to set up your expression.

5.) If you click on the box beside Result, a dropdown list will appear that will let you arrange your expression with all the integer/decimal type questions within your template. In my case my expression will look as seen below.

Note: If you are ever unsure how to use the provided result options, you can always click the question mark icon beside Result which will give you some sample equations

6.) Once you have completed your equation you are all set! Make sure you save your template and head over to its dedicated survey which will appear on the survey sidebar. From here let's add a new survey, and see how it all works!

7.) If you followed this tutorial correctly, you should see the math doing its work. I have entered 45º in our celsius input box and was returned 113º in fahrenheit.

Repeating Sections: Sums and Averages

You can now 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.

CREATE a new survey with a repeating section that includes a number field either integer or decimal.

  • Example: A section called "work hours" that repeats 30 times

CREATE a question within this section that contains "hours" and type "decimal"

CREATE another section called "Totals"

Section Total: SUM

CREATE a question that asks for the "total hours" and type "decimal"

ADD a "conditional logic rule" with the expression:

  • SECTIONSSUM ( Hours ) in the "Results" line.

NOTE: Use the ? to see the correct expressions formate

Section Total: Average

CREATE a new question called "average hours" and type "decimal"

ADD a "conditional logic rule" with the expression:

  • SECTIONSAVG ( Hours ) in the "Results" line.

NOTE: Use the ? to see the correct expressions formate

SAVE the form

See Math In Action

FIND your newly created survey

ADD a new survey

ENTER in multiple entries to your repeating section for "work hours"

"Total Hours" and "Average Hours" with automatically update for you

Did this answer your question?