Overview

Calculations for Hidden Values

You can use a special question type called a hidden value to store values from other forms and carry out calculations without it being visible to the mobile worker. The important field is the calculate field, which you can put calculation expressions. Some common examples include:

 

Operation ordering

Icon

Expressions in CommCare are evaluated left to right. The following example illustrates how this impacts expressions:

 

A and B or C

 

is equivalent to:

 

((A and B) or C)

 

Should you wish to evaluate expressions differently you must use parentheses to indicate which elements should be evaluated together e.g.:

 

A and (B or C)

 

 

Display Logic for Hidden Values

 

 

Examples

Simple Calculation Example

Icon

This is an example of a simple calculation where the Date of Birth is being calculated. The logic statement goes in the "Calculate Condition" of the Hidden Value.



Complex Calculation Example

Icon

This is an example of a hidden value where the Estimated Date of Delivery (EDD) is being calculated. The logic statement goes in the "Calculation Condition" of the Hidden Value.

 

For further guidance on doing calculations please see Hidden Values Tutorial Part 1: Adding Two Questions Using a Hidden Value and Hidden Values Tutorial Part 2: Calculations Using a Date.

Other calculations can be found on this page.

*EDD calculations: http://www.perinatology.com/calculators/Due-Date.htm and http://nrhm-mctsrpt.nic.in/MHFW/UI/FAQAnc.aspx