You are using an unsupported browser. Please update your browser to the latest version on or before July 31, 2020.
close
You are viewing the article in preview mode. It is not live at the moment.
Constructing Math Operations
print icon
INTERNAL USE ONLY

Math operations are mathematical formulas you can build within a Qualtrics survey.

In this article:

  • Constructing Math Operations
  • Using Math Operations

Constructing Math Operations

In some projects, you may need to create a mathematical operation that combines multiple values captured in a survey, such as an average value or a total sum. Math operations can display calculations like this in your data or the survey itself.

Math operations require a specific syntax in order to be calculated correctly by Qualtrics.

To start, the equation needs to be surrounded by $e{ }. You’ll then create your equation between the curly brackets. Each item inside of a math operation should be separated by a space.

As a simple example, the following operation adds 4 and 5:

$e{ 4 + 5 }

Performing operations on answers provided in the survey will be even more useful. For example, you may need to multiply the answer to a satisfaction question by a fixed number. We’ll need to use Piped Text to reference the given answer to the satisfaction question.

Piped Text is provided in a format like this:

${q://QID1/SelectedChoicesRecode}

To use Piped Text in a math operation, remove the ${ and } to look like this:

q://QID1/SelectedChoicesRecode

Now, we can set up the following math operation to multiply the given answer by 1.33:

$e{ q://QID1/SelectedChoicesRecode * 1.33 }

The available operations include:

  • Parentheses — $e{ ( 1 + 2 ) / 4 * 8 } resolves to 6
  • Exponents — $e{ 6 ^ 2 } resolves to 36
  • Square Roots — $e{ sqrt( 9 ) } resolves to 3
  • Absolute Values — $e{ abs( -23 ) } resolves to 23
  • Rounding — $e{ round( 10 / 3 , 2 ) } rounds 10/3 with 2 decimal places and resolves to 3.33

Math operations may not evaluate if they are formatted incorrectly. If your math operation displays an error message, then check for two common issues:

  1. Incorrectly formatted Piped Text. Make sure that when editing the format of the Piped Text, you have not made any changes to the rest of the Piped Text code.
  2. HTML spaces in the equation. To help troubleshoot, take a look at the HTML view of your question and see if the code   appears. If any do appear, remove them, and test your math operation again.

Using Math Operations

Math operations can be built in the Survey Flow, where each operation is saved as an Embedded Data field. The results of the equation are not displayed to the respondent by default, but are stored in your data.

math1.png

To display the results of the equation to respondents, you can use Piped Text that references the name of the Embedded Data field.

You can also build math operations directly in question or choice text. These operations are displayed to the respondent, but are not recorded in the survey results.

 math2.png

Note: You must save math operations as Embedded Data to be recorded in your data.

Feedback
0 out of 0 found this helpful

scroll to top icon