ENGAGE HELP CENTER
Activity-level Calculated answers
This page will serve as a guide to setting up calculations in the activities.
Calculated answers enable the creation of underlying calculations based on participants' responses in an activity. The results of these calculations are visible only to administrators during data export and analysis. Additionally, the calculation results can be shown to the participants and calculation-based participant reports can be prepared to tailor and personalize the information displayed to participants after completing the activity.
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

The administrators can choose to build equations using the user-friendly Calculation builder or opt for developing the necessary calculations with help of the JSON builder.

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 it is necessary to use constant values in the calculation, select the option Add in the section Constants and set up the constant with help of the available the Operations list.
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.
After the necessary calculations have been developed, it will be possible to apply them in the Conditional reports section and view them in the Engage Analytics tool and data export files.
Construct: Question

The Question construct is used to design calculations that utilize data from multiple submissions of an activity. The Question construct 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.
Position
The Position element is a part of the Question construct that indicates the sequence of the submissions and allows to work with data from multiple different submissions of the activity. By changing the Position element, various calculations between the submissions of the activity can be performed.
-1: Last or most recent submission.
-2: Second submission from last.
-3: Third submission from last.
etc.
0: First submission of the activity.
1: Second submission of the activity.
2: Third submission of the activity.
Position and Aggregation functions
While working with Aggregation functions, the Position element can come in handy in comparing multiple submissions.
0:4 : This Position range would compare the first five submissions.
-3:-1 : This Position range would compare the last three submissions.
The Question construct can be integrated into any Calculation builder construct that supports numerical operations by replacing the number entry field with the Question element.
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.