Popular Help Content
Display Logic, or "also known as Skip Logic" as it is sometimes called, is used to display questions based on previous answers or specific logic.
This page demonstrates how to set up Display Logic in your CommCare application.
Display when there is or is not an answer in a question:
- To show a question when there is ANY answer to a previous question, use #form/previous_question != '' (that is two single apostrophes: null). As long as there is some answer input for previous_question, this returns true and your current question will display.
- To show a question when there is NO NOT an answer to a previous question, use #form/previous_question = '' (that is two single apostrophes: null). This could be because previous_question was skipped, or because the user proceeded past previous_question without inputting an answer.
- Save the answers to TT1 and TT2 as case properties
- Place logic on the TT1 question: #case/TT1 != 'yes'
- Place logic on the TT2 question: (#case/TT1 = 'yes' or #form/TT1 = 'yes') and #case/TT2 != 'yes'
Displaying based on a range:
- You can also show a specific message when the answer to a question is within a specified range. For example, you might have different messages based upon the score from a test: (Good, Fair, Poor)
- Create three different Labels, each of which will represent one of the outcomes (Good, Fair, Poor).
- In the Display Condition, enter a value which will be True if the label should be displayed. We'll say that Good is greater than 75, Fair is between 75 and 50, and poor is below 50. The three display conditions would be:
- Good: #form/score > 75
- Fair: #form/score <= 75 and #form/score > 50
- Poor: #form/score <= 50
Displaying based on a date:
You can also write display logic for questions you want to appear at a certain time of year using format-date. For example, if you'd like a question to appear only in the month of August, you'd put format-date(date(today()), '%n') = 8 in the display condition. See format-date on the functions page.