x

Math Operations

Advanced Building

Step-By-Step

Use code to perform math operations in your survey. You can then display the output to the respondent and record it in your data.

Set up a Math Operation

  1. Paste the following code into your question text or answer choice text:
      $e{ your expression here }
  2. Replace “your expression here” with the math operation you want to use. The output for the expression will be displayed wherever you put the code into your survey. Examples:
    • $e{4 + 4} — Resolves to 8.
    • $e{(4+4)/2} — Resolves to 4.
    • $e{4*4} — Resolves to 16.
Use Piped Text in a Math Operation

If you want to run an equation using numbers that were entered by the respondent in a previous question, you can use piped text code:

  1. Generate your piped text code from the Piped Text tab. You will need to know which questions you are piping from.
  2. Paste the piped text code without ${} into the math expression. The system will pull in the numbers the respondent has entered into the previous question and run the equation.
Record the Output

To record the output of the equation with your data

  1. Place your math operation code into the question where you want the output displayed to the respondent.
  2. Click the Survey Flow button and then click Add a New Element Here.
  3. Make the element an Embedded Data element.
  4. Click Output.
  5. Click Set a Value Now and paste your math operation code in as the value.

Your downloaded data will contain a column called “output” which will contain the outputs for each respondent.

More Information

Qtips

  • Remember the order of operations. Operations within parentheses will be evaluated before the rest of the operations.
  • Division operations can sometimes generate a number with many decimal places. For example, $e{10/3} resolves to 3.333333333. To round, place the word “round” in your code and specify the number of decimal places you would like displayed.
      Example: $e{round(10/3,2)} will now resolve to 3.33. The “round” tells it to round up or down, and the “,2” tells it to round to two decimal places after the operation is done.