Branching Logic
Copied from REDCap Help and FAQ:
You want to ask a survey participant to specify their ethnicity when ‘Other’ (option code 9) is selected for the multiple-choice variable ethnicity
. Add the branching logic to the following field, specify_ethncity
:
Click the green arrow icon above a question to open the branching logic editor. Remember to apply the logic to the field that should be conditionally hidden or displayed.
Use Advanced Branching Logic Syntax or the Drag-N-Drop Logic Builder to add logic.
Branching logic based on responses to checkboxes uses special syntax. From the REDCap Help and FAQ:
When a form is repeated in multiple events in a longitudinal project, branching logic refers to values in the current event by default.
To use data entered in a different event, you must include the unique event name in brackets before the variable name, in the format [unique_event_name][variable_name]. For example, to base logic on a participant’s age at baseline, you might use [baseline_arm_1][age].
You can also use a smart variable to refer to another event contextually. For example, the smart variable [previous-event-name] will find the value entered in the previous event, as in [previous-event-name][variable_name].
Read more about longitudinal data collection.
Copied from REDCap Help and FAQ:
Branching logic is defined on a field-by-field basis. Although you can create sections using section header fields, you cannot apply branching logic directly to a section or a section header.
However, you can conditionally skip an entire section on a survey if you apply the same logic to all fields within in the section (i.e., all fields between two section header fields). If branching logic hides all fields in a section, the section’s header will also be hidden. If your survey is set up to display one section per page, the entire page will be skipped. To quickly apply the same branching logic to multiple fields, select them in the Online Designer and click the branching icon in the “Quick-modify field(s)” menu.
If a survey section can be moved to a standalone instrument, consider using Form Display Logic for form-level branching. Form Display Logic can disable an entire instrument for data collection until certain conditions are met. The form will still appear on the record status dashboard, but the form will be inaccessible and greyed-out (unless you hide the form using a custom record status dashboard).You can also skip entire surveys by using:
- The Survey Queue, found in the Online Designer; or
- Conditional logic for Survey Auto-Continue, found in each individual instrument’s survey settings
The Online Designer preview won’t evaluate branching logic. Instead, test your branching logic on a data entry form or survey by entering test data while in development mode.
If you encounter a problem while entering test data in a form, REDCap will display a popup message. Common issues include:
- Logic syntax issues: Non-existing variable names or invalid conditions
- Data errors: Data exists in fields that should be hidden by new branching logic conditions
If an instrument includes branching logic, carefully review it every time modifications are made, as some field edits can affect the branching logic. If your project is in production status (highly recommended when collecting real data), you will have the chance to review the effects of draft modifications.