What do you need help with?
Search the knowledge base, browse our resources, and visit our forum for more detailed information
Search the knowledge base, browse our resources, and visit our forum for more detailed information
Last updated: 15 Feb 2022
Some advanced forms may require an internal calculation to take place as part of the form (rather than afterwards during the analysis). This can be done by adding a Calculation and writing the mathematical expression into the question label field.
A mathematical expression could be as simple as 5 + 1
, but most likely it
would include reference to another question.
Referencing other questions in your calculation question requires giving other
questions fixed names through the question settings, such as girls
or
income
. When referencing those questions, you should always use the unique
question name (not label) - ${girls}
or ${income}
For example, if you want to convert the answer to a question about someone’s
income into another currency (such as Rwandan Francs to US Dollars), you should
write ${income} div 688
.
You can also use the answer to this Calculate question for other purposes, such as building your skip logic (for example only ask a follow-up question above a certain income threshold) or by displaying it inside a Note (see here for help on how to display the response to one question in the label of another question).
There are a lot of different options available, such as the round() function
(e.g. round(${int_1} div ${int_2}, 1
) will round the result of a division to a
single decimal). For a list of some of the many mathematical expressions that
can be used in this field, please see
XForm specifications on calculation functions
for the technical background of all the functions available in KoboToolbox and
XLSForms. For advance use of calculations in KoboToolbox, please refer to
this article.
Operator |
Description |
---|---|
|
Addition |
|
Subtraction |
|
Multiplication |
|
Division |
|
Equal |
|
Not equal |
|
Less than |
|
Less than or equal to |
|
Greater than |
|
Greater than or equal to |
|
Or |
|
And |
|
Modulus (division remainder) |
|
Power / exponent |
Did you find what you were looking for? Was the information clear? Was anything missing?
Share your feedback to help us improve this article!
KoboToolbox is maintained by Kobo Inc.