ENGAGE HELP CENTER
Calculated answers
This page will serve as a guide to setting up calculations in the project.
Calculated answers enable the creation of underlying calculations based on participants' responses in activities. The results of these calculations are visible only to administrators in the Participants page, during data export and analysis.

You can apply calculations in Response Alerts to triage participants based on the calculated value after activity completion or on values submitted in multiple submissions. Evaluating values from multiple submissions enables a dynamic review process by considering patterns or trends across repeated inputs.

Are you working with activity-level Calculated answers?

Proceed to the section Activity-level calculated answers.
Use cases

Among countless other options, here are some examples of well-known health-related risk calculation models and index calculations that can be set up within the Engage activities with help of the Calculated answers functionality:
- Body Mass Index calculation,
- SCORE2, SCORE 2-OP CVD risk calculation,
- Breast cancer risk calculation,
- EQ-5D standardised calculation of health-related quality of life,
- Patient-reported outcome measure (PROM) scores,
- etc.
Activity question type supported in Calculation builder

Here are the question types that can be included in the equations of the Calculation builder:
- Radio Button Group
- Checkboxes
- Dropdown
- Boolean
- Single-Line Input (Input Type: Number, Date, Text)
Developing calculations

Access the Calculated answers in the upper right corner of the project page.

New calculation
The option New calculation will open a new blank calculation builder view that will have to be updated following the below steps.

1. Insert the Title of the calculation.
2. If constant values are necessary in the calculation, select the option Add in the section Constants and set them up using the available Operations.
The Operations section that contains all of the available equation templates is expanded after selecting the default value "1" or "10" in the Constants or Calculation builder field.
3. In the Calculation section, follow the logical sequence for building equations and use the available Operations to construct the required equation. All changes made in the calculation builder are automatically saved.
To add new elements to your equation, click on the round bracket on the right side of the equation.
Clicking on the round bracket will add a new element into your equation.
Supported constructs

Engage supports various calculation constructs.

Add (Sum): Use to add two numbers together.
Subtract: Use to subtract one number from another.
Multiply: Use to multiply two numbers.
Divide: Use to divide one number by another.
Negate: Use to find the opposite value of a given number.
Power: Use to multiply a number by itself a specific number of times.
Root: Use to calculate the root of a number.
Sqrt: Use to find the square root of a number.
Square: Use to square a number.
Here are some simple examples how these equations have been applied.
Here are some simple examples how these equations have been applied. Calculations are displayed when developed with help of JSON editor as seen below.
["Power", 2, 3]                   # 2^3=8
["Root", 9, 2]                    # √9=3.0
["Root", 8, 3]                    # ∛8=2.0
["Sqrt", 9]                       # √9=3.0
["Square", 4]                     # 4^2=16
Exp: Use to calculate exponential functions.
Log: Use to return the natural logarithm of a number.
Log2: Use to return the base-2 logarithm of a number.
Log10: Use to return the base-10 logarithm of a number.
This is how calculations are displayed when developed with help of JSON editor.
["Exp", 2]                        # e^2≅7.389
["Log", 2.7183]                   # ln(2.7183)≅1.0000
["Log2", 8]                       # log2(8)=3.0
["Log10", 1000]                   # log10(1000)=3.0
Round: Use to round a decimal number to a specified number of decimal places.
Here are some simple examples how these equations have been applied.
["Round", -5.123456, 2]           # -5.12
["Round", -5.123456, 0]           # -5.0
["Round", -5.123456]              # -5
Comparisons
Comparison operators allow you to compare two values and return True or False based on the condition. They serve as supportive operators for such additional constructs as If-statements and Switch-Case statements.

Equal: Use to check if two values are equal.
Greater: Use to check if the value on the left is greater than the value on the right.
GreaterEqual: Use to check if the value on the left is greater than or equal to the value on the right.
Less: Use to check if the value on the left is less than the value on the right.
LessEqual: Use to check if the value on the left is less than or equal to the value on the right.
NotEqual: Use to check if two values are not equal.
Aggregation
Aggregation functions are useful for performing calculations on a set of values and returning a single result.

Max: Use to return the maximum value in a set.
Min: Use to return the minimum value in a set.
Average: Use to return the average value of a set.
Median: Use to return the middle value of a set.
Length: Use to return the length of a set (e.g., number of items in a list).
Any: Use to evaluate items in a set and return True if any item is true; otherwise, return False.
All: Use to evaluate items in a set and return True if all items are true; otherwise, return False.
Checking for membership
Functions that check for membership are helpful when verifying if an answer is part of a predefined group.

In: Use to return True if the answer is in the defined group.
Not in: Use to return True if the answer is not in the defined group.
Contains any of: Use to return True if the answer contains any element of the defined group.
Contains all of: Use to return True if the answer contains all elements of the defined group.
Contains none of: Use to return True if the answer contains none of the elements of the defined group.
Typecasting
Typecasting functions convert a variable value from one type to another.

Int: Use to convert a value into an integer.
Float: Use to convert a value into a decimal (floating-point) number.
Additional constructs
Engage also supports several additional constructs.

Question values: Values provided as answers in the activity questions can be applied in calculations via the construct Question in the Operations list. Single-Line Input, Radio Button Group, Dropdown and Checkboxes questions can be added in calculations.
Constant values: Defined in the Constants section these values can be used in calculations. You can access these values via the Constant construct in the Operations list.
If-statements: Use to return numeric values based on logical expressions. For example, you can use an If statement to check conditions and return a result accordingly.
Switch-Case statements: These can execute different scenarios based on a variable. For example, return a numeric value based on a textual input provided in survey answers.
Text: This instructs the calculation builder to treat the question response as text input, which is useful for questions with predefined answer choices and expressions checking for membership.
Construct: Question

The Question construct is used to design calculations that extract data from activity submissions, allowing you to reference multiple activities within a single calculation.

It consists of three elements:
Activity: Select the project activity where the desired question is located.
Question: Select the question that needs to be included in the equation.
Position: Select the sequence of the submission that should be taken into consideration in the equation.
The Question construct can be incorporated directly into any Calculation builder construct that supports numerical operations by replacing the number input field with the Question element.

If your question isn’t numeric, you may need to process them with Switch or If operations to create calculations based on participants’ responses.
Position
The Position element, part of the Question construct, identifies the sequence of submissions, enabling calculations based on data from multiple activity submissions. By adjusting the Position element, various calculations between submissions can be performed:
-1: Refers to the last (most recent) submission. This is the default and most commonly used option.
-2: Refers to the second-to-last submission.
-3: Refers to the third-to-last submission.
(And so on.)

0: Refers to the first submission.
1: Refers to the second submission.
2: Refers to the third submission.
(And so on.)
Position and Aggregation functions
The Position element is especially useful when working with Aggregation functions (Max, Min, Average, Median, Length, Any, All), enabling comparisons across multiple submissions. Examples:
0:4 : Compares the first five submissions.
-3:-1 : Compares the last three submissions.
The Project-level Calculated answers are updated with every participant's activity submission. The trends over time can be observed in the Participant profile section.
Example of an equation

To create an equation effectively, start with the basic formula and add specific components step by step. Let’s use the PHQ-9 calculation as an example to illustrate this process. The PHQ-9 calculation works by assigning points to specific answer options and adding up the total points across all nine questions in the scale.

1. Start by choosing the Sum formula.
2. Use the Switch function to assign points to the answer options of the PHQ-9 scale questions.
3. Add the Question element to the header of the Switch function. In the field Activity select the Engage survey containing the PHQ-9 questions.
4. Similarly, in the Question field, select the corresponding question from the PHQ-9 scale.
5. Assign a value to each answer choice for the selected question.
6. Repeat this process for all the questions in the PHQ-9 scale.
We use cookies in order to secure and improve the Longenesis web page functionality, as well as to optimize your experience within this page.
Please see our Privacy policy for more information on how we use the information about your use of our web page. By continuing to use this web page you agree to our Privacy Policy.