# 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:

• Age in years: int((today() - date(#form/dob)) div 365.25)
• Age in months: int((today() - date(#form/dob)) div 30.4)
• Age in weeks: int((today() - date(#form/dob)) div 7)
• Estimated Date of Delivery (EDD) from Last Menstrual Period (LMP): date(#form/lmp + 280)
• Summation of three questions: int(#form/question_one) + int(#form/question_two) + int(#form/question_three)

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

• You can put a display condition in a hidden value
• The hidden value will hold the null value '' until its display condition is met.  Once its display condition is met, it holds the calculated or loaded value.

• If you update the case from a hidden value, it will only update the case if its display condition is met.

# 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.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}