ENGAGE HELP CENTER
Calculated answers
This page will serve as a guide to setting up calculations in the activities to be able to apply them in drawing valuable analytical conclusions and creating conditional reports to the participants.
Calculated answers is a helpful tool for drawing invaluable insights from the submitted activity responses.

This feature supports both creating underlying calculations based on the responses given in the activity, visible only to the administrators when exporting and analysing the activity response data, as well as preparing calculation-based participant reports that will help tailor and personalise the message displayed to the participants.

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.
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 to be able to easily recognize it in the further steps of developing the activity in case multiple calculations are planned.
2. If it is necessary to use constant values in the calculation, new entry in the section Constants can be created using any formula from the Operations list.
3. In the section Calculation following the logic sequence of building equations and with help of the available Operations, put together the necessary equation. All the changes made in the calculation builder are auto-saved.
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.
To add new elements to your equation, simply click on the round bracket located on the right side of the equation.
Clicking on the round bracket will seamlessly integrate a new element into your equation, such as a fresh addend.
Example of an equation

It's essential to methodically construct equations, starting with the fundamental formula and gradually incorporating specific elements. Let's delve into the process of creating a PHQ-9 calculation as an example.
1. The PHQ-9 calculation is based on attributing points to predefined answer options and summing up the total points accrued across all nine questions of the scale. Begin by selecting the Sum formula.
2. Assign points to the various answer options of the PHQ-9 scale questions by employing the Switch construct for each of the nine questions.
Such equation will suit surveys and other activities where it is required to sum the chosen responses.
Supported constructs
Multiple different calculation constructs are currently supported by Engage.

- Add (ie., Sum) - use to summarize two numbers.
- 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 determine what is the opposite value of the given number.
- Power - use to multiply the number by itself a specific number of times.
- Root - use to find the root of a number.
- Sqrt - use to find the square root of a number.
- Square - use to find the squared value of a number.
Here are some simple examples how these equations have been applied.

["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
This is how calculations are displayed when developed with help of JSON editor.
- 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 return a decimal number rounded to the 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 can be used to compare two values and return either the value True or False based on whether the condition has been met. They serve as supportive operators for such additional constructs as If-statements and Switch-Case statements.

- Equal - use to check if the values on either side of the operator 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 lesser than the value on the right.
- LessEqual - use to check if the value on the left is either less than or equal to the value on the right.
- NotEqual - use to check if the values on either side of the operator are unequal.
Aggregation
Aggregation functions will be useful when it is necessary to perform a calculation on a certain value set in order to returns a single value.

- Max - use to return the maximum value of a set.
- Min - use to return the minimum value of 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, for example, to return the number of items in a list.
- Any - use to evaluate items in a set and determine which are true. If any item on the list is true, the function will return the answer True. Otherwise the answer will be False.
- All - use to evaluate items in a set and determine which are true. If all items on the list are true, the function will return the answer True. Otherwise the answer will be False.
Checking for membership
Functions that check for membership will be useful when it is necessary to verify if the response of a question with pre-defined answer choices is a part of the answer choice group defined in the Calculation.

- In - use to return TRUE if the answer given falls within the defined group.
- Not in- use to return TRUE if the answer given does not fall within the defined group.
- Contains any of - use to return TRUE if the answer given contains any of the elements of the defined group.
- Contains all of - use to return TRUE if the answer given contains all of the elements of the defined group.
- Contains none of - use to return TRUE if the answer given does not contain any of the elements of the defined group.
Typecasting
Typecasting functions can be used to convert a variable value from one type to another.

- Int - use to convert the specified value into an integer number.
- Float - use to convert the specified value into a decimal number or fractional form.
Additional constructs
Engage supports several additional constructs.

- Constant values that are defined in the section Constants or numeric values provided as answers in the activity questions can be applied in calculations, as well. The defined constant values or equations, as well as answers given in the activity will be accessible via the construct Constant or Question in the Operations list. Single Input, Radiogroup, Dropdown and Checkbox questions can be added with the Constant or Question construct.
To easily work with incorporating the questions of the activity in the calculation, it is advisable to assign personalized "Name" or hidden ID values to all of the questions and pre-defined answer choices.

Access the activity element Settings in the activity Designer view that's available in the step "Survey/Screening/Feedback questions" ("Content" for the Custom activity). Populate the fields "Name" in the "General" settings for all questions and the left column of each answer choice in the "Choices" settings for questions with pre-defined answer choices with short, personalized identifiers. Learn more here.
- If-statements can be used to return numeric values based on logic expressions. Here is a simple example on how if statements can be built.
- Switch-Case statements can be used to execute different kind of scenarios based on a variable. For example, with this construct it is possible to return a numeric value based on a textual input given in the survey answers.
- Text element can be used to instruct the Calculation builder to recognize the question response as text input, which can be applied to questions with pre-defined answer choices to include them in 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.
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.