Calculated fields
A calculated field can use previously submitted answers to calculate and display a value.
You can use calculated fields to determine values based on the values of previous fields. Here we will determine the participant’s age and body mass index (BMI) based on their date of birth and their height and weight.
Calculate a participant’s age
Activity
- Click
Add field
. - Choose Calculated Field for the
Field Type
. - In the
Field Label
, type Your age. - In the
Variable Name
, type age. - In the
Calculation Equation
, type:datediff([dob],"2020-01-01","y")
REDCap understands terms like ‘now’ and ‘today’, but they are not recommended for calculating age because they will lead to variation in values over time. This is why we select a set date such as January 1 or the project start date.
Calculate a participant’s BMI
Extra activity
Here, we are going to use the ‘height’ and ‘weight’ values provided by the user to calculate their body mass index (BMI).
- Click
Add field
. - Choose
Calculated Field
for theField Type
. - In the
Field Label
, type Your Body Mass Index (BMI). - In the
Variable Name
, type bmi. - In the
Calculation Equation
, type:[weight]*10000/([height]*[height])
.
REDCap understands many calculation functions you might be familiar with from Excel, including IF() statements.
Calculated fields cannot be tested in the Preview mode.