Display Logic, also known as Skip Logic, 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 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.

Display based on previous answers:

To show a question if a previous question was answered "yes" this time OR last time.  This is common for things like Tetanus (TT) injections and Antenatal Care visits.  When the same form is used across multiple visits, you want to skip the first TT question and only ask about the 2nd tetanus if the beneficiary answered "yes" for TT1 at any time (this visit or any previous visit).  

  • 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: (GoodFairPoor)
    • Create three different Labels, each of which will represent one of the outcomes (GoodFairPoor).
    • 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.