Hidden Values allow you to build advanced or complex functions into your CommCare application without involving the mobile user. Before using this tutorial, we recommend you review the two articles below (or know the requisite skills):
In the Hidden Value Calculations Tutorial, you will learn the following:
- The possible uses of Hidden values
- How to use the Advanced Expression Editor Box
- How to do basic calculations in a Hidden Value
- How to write "if" statements
- How to display the output from a calculation
All About Hidden Values
When you were learning how to use the CommCare Form Builder, you may have noticed the following question type:
This is a Hidden Value (formerly called a "data node"). A Hidden Value is a special question type because the mobile user cannot see it. This means you can use it to do a lot of advanced or complex functions without involving the mobile user.
Here are some common uses of Hidden Values:
- To calculate something: Sometimes you may wish to perform a calculation in a form. For example, you may ask someone their birthdate and then want to calculate their age. You can directly ask the mobile user to input their birthdate using a date type question, and then you can use a hidden value to transform the entered value into their age! Or you may have a series of questions that ask how much land a farmer has under cultivation for different crops. You can then use a hidden value to add them up.
- To store a value from another form: Since CommCare uses case management, sometimes you will want to carry data across forms. For example, in a registration form, you may ask someone their birthdate. Later in a followup form, there may be a question that you want to ask an individual only if they are above a certain age. You can use a hidden value as a "box" to hold the person's birthdate, so that you can refer to it for the followup form.
- To account for something in data exports: You may want to have a column in your data exports that identifies people who are at high risk for pregnancy complications. Say that you define high risk as someone over a certain age, with at least one danger sign, and in their third trimester of pregnancy. To identify people at high risk for pregnancy complications, you could have someone look at all three of those values or you could create a hidden value that has the value "yes" to determine if all of those conditions are true.
This may sound a bit abstract but we are going to walk through several possible ways to use a hidden value by building upon the form you created in the Beginner's Tutorial. Then you can go to our extensive page of common logic and calculations to do even more complex things with hidden values!
In the first part of the tutorial, you will learn how to do basic math with questions.
Go to the next section