Display conditions, basics 1 – Overview

Compatibility:IdSurvey 7IdSurvey 8

Display conditions let you display an object of the questionnaire according to specific conditions.

Objects you can apply Display Conditions to are:

  • answer options
  • grid/matrix rows
  • grid/matrix columns
  • advanced grid/matrix cells
  • questions
  • groups of questions
  • pages
  • sections

Conditions can include values as:

  • answer codes
  • values inserted in text answers (text, numbers, dates), rating and sliders.
  • contact information

In following example we use a display condition to display a page just if the respondent is a female and in a previous question answered “yes, I usually shop online”.

 

display_condition1

In question Q7 you ask the respondent if he/she shops online.

We also know that in the Contacts Management database there are two possible values in the “Gender” field: F for female and M for male.

We want page Q8 to display only ifthe respondent selected option 1 or 2 in question Q7 and if the respondent is also female.

The syntax for this condition is: if((Q7==1||Q7==2)&&({sesso}==f))

display_condition2

Let’s analyze this string.
First thing: the display condition has to be written within if(  )

if(condition)

Note

  • You can only use a single if ( ) function per item, but you can add multiple conditions inside it.

The condition in the example has multiple sub-conditions. First condition (withing first brackets) checks answer to question Q7.
Specifically, if the code selected to question Q7 is equal to 1 (Q7==1) or 2 (Q7==2).

To specify “equal to” you have to use two equal symbols == .
To write “or” use two symbols || .

So here’s our condition:if(Q7==1||Q7==2)

We then have to add the part of the condition referred to “gender” contacts database field. Contacts associated to this survey and uploaded with the Excel file in Contacts Management have “F” for female and “M” for male in “Gender” field.

To refer to a contacts database field you have to include the name of the field between curly brackets { }.

The syntax of this condition is:{gender}==f.

Let’s see how to insert it into the complete condition. If first condition (first round bracket) AND second condition (second round bracket) are both  true, then the entire condition is true.

To write “and” you need two symbols && .

if( (Q7==1||Q7==2) && ({gender}==f}) )

As you can see in the example, if you use both logic operators “and” and “or”,you have to use round brackets to separate conditions, as indicated in the following examples:

if((Q1 == 2 && Q2 == 3) || (Q1 == 1 && Q2 == 4)) is correct.


if(Q1 == 2 && Q2 == 3 || Q1 == 1 && Q2 == 4) is not correct.

or:

if((Q1 == 2 || Q1 == 1) && (Q2 == 3 || Q2 == 4)) is correct.

if(Q1 == 2 || Q1 == 1 && Q2 == 3 || Q2 == 4) is not correct.

This will indicate in which order to process conditions. In this case, IdSurvey processes the first condition (Q7==1||Q7==2), then the second condition ({gender}==f) and then it processes the content of the outer brackets that includes the two sub-conditions (condition1 && condition2).

IdSurvey is able to process really complex expressions: for example, you can use other comparison symbols, check text or number inserted in a text question or do math calculations.

The same condition above can also be written as:if(Q7!=3&&{gender}==f})

For more information on display conditions please consult the specific Display Conditions article you can find in this Knowledge Base.

Leave A Comment?