Calculated Questions calculates a result on behalf of previous answers in the form, and inserts the results into your form. Calculated questions uses a combination of previous question answers and constants in a formula to calculate a value
You can use answers from both Slider and Number questions to calculate answers in regular forms.
In Score forms you can use answers from: Slider, Number, Yes/No, Smiley, and Multiple Choice. You will be required to assign a value to each possibility in a possibility question, the question reference will then use the value associated with the selected possibility
To create Calculated Questions:
- Choose Calculated in Question Type.
- Under Answer Specification, type in the formula that you want to use for calculation. When choosing the questions, you want to include for your formula, use eg. Q1 for Question 1.
- If the question is in a correct format (number or slider) the question will be highlighted in blue to mark that Greenlight Guru Clinical has included the question in the formula.
- Press Verify Formula.
- If the formula is valid, a green text will appear under the formula and the formula is now ready to be used in your form.
The calculation will be shown in the form the same way a question is shown, and the answer to the calculation will appear as soon as the questions used in the formula have been answered.
When questions are used in a formula, i.e they are blue, there is a link between the question and the formula. It will automatically update the question number should you want to change the order of the questions in the form.
Calculated questions do not work in Inclusion/exclusion forms
Operator |
Function |
Example |
+ |
Addition |
Q1 + Q2 |
- |
Subtraction |
Q1 – Q2 -2 |
/ |
Divide |
Q1/(Q2+1) |
* |
Multiply |
Q1*4 |
^ |
To the power of |
Q2^4 |
|
Comparators |
|
== |
Equals, if the two values are the same will evaluate to TRUE, if not evaluates to FALSE. Can be used as condition in IF and ternary operator |
Q1==5 |
!= |
Not Equal, if the two values are NOT the same it will evaluate to TRUE, else to FALSE. Can be used as condition in IF and ternary operator |
Q2!=Q1 |
>= |
Greater than or equal Can be used as condition in IF and ternary operator |
Q2>=3 |
<= |
Less than or equal Can be used as condition in IF and ternary operator |
Q5<=Q1 |
< |
Less than Can be used as condition in IF and ternary operator |
Q1<Q2 |
> |
Greater than Can be used as condition in IF and ternary operator |
2>Q1 |
|
Constants |
|
PI |
PI, evaluates to: 3.141592653589793 |
PI + 1 = 4,14 |
E |
Eulers number, evaluates to: 2.718281828459045 |
E^2 = 7,389 |
Available expressions:
Expression |
Definition |
Example |
ISANSWERED(Q{id}) |
If the referenced question has been answered returns TRUE, if not returns FALSE. Mainly to be used as a condition in the IF expression. |
ISANSWERED(Q1) If Q1 is answered e.g. Q1=Yes ISANSWERED(Q1) = TRUE |
SQRT(x) |
The squareroot of x X can be both a question reference and a constant |
SQRT(Q1) |
EXP(x) |
E raised to the power of x |
EXP(2) = E2 = 7,389 |
SUM |
Will SUM over the provided values and return the sum. Separate the values with semicolon “;”. A range using “:” will not work, e.g. SUM(Q1:Q5). SUM skips unanswered questions when evaluating Accepts question references and constants |
SUM(Q1;Q2;Q4) If you sum over questions all without answers it returns 0. |
MIN |
Returns the min of the provided values. Separate the values with semicolon “;” A range using “:” will not work, e.g. MIN(Q1:Q5). Does not skip unanswered questions, will not evaluate. Accepts question references and constants |
MIN(Q1;Q2) E.g. MIN(1;10) = 1 |
MAX |
Returns the max of the provided values A range using “:” will not work, e.g. MAX(Q1:Q5). Does not skip unanswered questions, will not evaluate. Separate the values with semicolon “;” Accepts question references and constants |
MAX(Q1;Q4;2) E.g. MAX(5;3;2) = 5 |
LN |
Returns the natural logarithm of x X can be a question reference or a constant |
LN(24) |
LOG10(x) |
Returns the base 10 logarithm of x X can be a question reference or a constant |
LOG10(Q1) |
LOG2(x) |
Returns the base 2 logarithm of x X can be a question reference or a constant |
LOG2(5) |
LOGB(base;x) |
Returns the base B logarithm of x. Expects two parameters: base;x Base is the base of the logarithm and x the value you want the logarithm of. |
LOGB(3;Q1) |
IF(condition;then;else) |
Conditional, if the CONDITION is true, use THEN value, otherwise use ELSE value Can use ISANSWERED as a condition THEN and ELSE values accept question reference and constants. |
IF(Q1>2;Q1;1) Q1= 5 IF(5>2;5;1) = 5 |
QMAX{ID} |
Only works for possibility questions (not multiple response) in score forms. Accepts a single possibility question reference e.g. Q1. Will return the max value of the possibilities available on the question. |
If Q1 had the possibilities: A =1, B=5, C =15 Then QMAXQ1 would evaluate to 15. |
? : Ternary operator |
Functions similar to the IF expression CONDITION ? x : y |
ISANSWERED(Q2) ? Q1 : Q3 If Q2 is answered it would output Q1, if not outputs Q3 |
Does not support implicit multiplications e.g.: 3(Q1) instead use 3* Q1.
Fractions need a leading number e.g: 1/4 is OK, .25 is not.
Calculated questions do not work in Inclusion/exclusion forms
Calculated Questions in Greenlight Guru Clinical:
The layout of the calculated question above will be as seen in the picture below. Here the height and weight have been entered and the BMI has automatically been calculated and inserted into the BMI question field. When exporting the data, the BMI will appear in the export the same way as the rest of the data.