IdCode: display conditions

Compatibilità:IdSurvey 5IdSurvey 6

For other articles, consult the “IdCode” section of this knowledge base.
For other articles on display conditions search “display condition” in the knowledge base.

In this article you can learn more on designing display conditions with IdCode programming language.

To write the questionnaire of your survey with IdCode you can:

  • click on “Import from script”, if you’ve just created your survey and it’s the first time you open “Questions” section
  • click on the gearwheel button of the pages box and then on “IdCode – Display script” if you want to work on the code of the entire questionnaire
  • click on the “IdCode” button you find on the top part of each page to work on the code of a single page

Display conditions influence and lead the interview path and they’re used to set when an item of the questionnaire has to be displayed to the respondent.

Display conditions can be inserted in IdCode after any item (sections, pages, group of questions, questions, answers, rows and columns) written in quotation marks and preceded by /F (for example /F “if(Q1==1)”
If correctly written, Display condition are displayed in orange in IdCode.

idcode_display

TIP: For a quick check on display condition coherence and consistency click on the gearwheel button of pagex box tools then on "Filter & Logic Control" and run a first check on what you wrote. 
Be always sure you wrote the symbols correctly, you used parenthesis to specify the order and priority of the instruction and you closed the instruction(s) with round brackets.

Comparison symbols that you can use to write your display condition are:

= = equal
!= different
< less than
> greater than
<= less than or equal to
>= greater than or equal to

Here’s some display conditions and functions you can set near to any item of your questionnaire:

Display if I answered with a specific option

Syntax:
if (‘question code’ ‘comparison symbol’ ‘answer code number’)

Example:
if (a01==02)

Display if I answered with specific options in different questions

Syntax:
if (‘question code’ ‘comparison symbol’ ‘answer code number’ ‘logical operator’ ‘second question code’ ‘comparison symbol’ ‘answer code number’…)

Example:
if(a10==01||a11==01)
if( (a01==98||a01==99)&&b3==01)
if( (a01==01||a01==02)&&(b3==01||b5==12))

Display if I answered an open end question with a specific value

With this codification you check the open end answer given to a question. To do this you have to write code of the question between square brackets.

Syntax:
If(‘[question code between square brackets]’ ‘comparison symbol’ ‘numerical value’)

Example:
Display if at question a03 I wrote a number greater than 19
if([a03]>19)

Display if a contact field contains a specific value

It’s possible to control the value of a field (e.g.: gender) in the contact database. In this case you have to put the name of the field between curly brackets.

Example:
Display is gender is male:
if({gender}==M)

FUNCTIONS

CompareDate function

This function compares two dates (example: display the question just if the date of birth is greater than a specific date).

Syntax:
CompareDate date1,date2 (CompareDate DD/MM/YYYY,DD/MM/YYYY)

It gives back -1 if date1 is inferior (earlier) to date2, 0 if they’re equal and 1 if date1 is greater (following) than date2.

Example:
Display question just if the date of birth inserted in quest1 is greater than 01/01/1970

if(CompareDate [quest1],01/01/1970==1)

ContainsText function

It checks the presence of a specific text within an open end answer.

Syntax:
ContainsText questioncode,text

It gives back 1 if the text searched is present, it gives back 0 if the text searched is not present.

Example:
Display a question just if in the open answer text of quest1 the word ‘sea’ is present
if(ContainsText [quest1],’sea’==1)

CountCode function

It allows to know the number of selected options in a multiple choice question.

Syntax:
CountCode questioncode

It gives back the number of selected options to the question

Example:
Display the question just if for quest1 3 or more options were selected
if(CountCode quest1 >=3)

CountResponsesWithCode function

It allows to know, in a specific group, the total number of questions that were answered with a specific option.

Syntax:
CountResponsesWithCode questioncode1,questioncode2,. . ., questioncodeN, Answercode

It gives back the total number of questions in group questioncode1,questioncode2,. . ., questioncodeN answered with the option ResponsesWithCode

Example:
Display question just if interviewee answered with code 99 at least to 3 of the question in group quest1,quest2,quest3,quest4,quest5,quest6
if(CountResponsesWithCode quest1,quest2,quest3,quest4,quest5,quest6,99 >= 3)

CountResponsesWithText function

It allows to know the total of questions answered with a specific text in a specific group.

Syntax:
CountResponsesWithText questioncode1,questioncode2,. . ., questioncodeN,’text to search’

It gives back the total of questions in group questioncode1,questioncode2,. . ., questioncodeN whose answer contains ‘text to search’

Example:
Display question just if interviewee answered with text ‘mouse’ at least to 3 of the question in the group quest1,quest2,quest3,quest4,quest5,quest6

if(CountResponsesWithText quest1,quest2,quest3,quest4,quest5,quest6,’mouse’ >= 3))

CheckQuota function

It allows to know the total of interviews completed in a specific sampling cell.

Syntax:
CheckQuota ‘quotaname’

It gives back 1 if the sampling cell with name ‘quotaname’ is closed, 0 if it’s open

Example:
Display the question just if the sampling cell called ‘NorthEast’ is closed
if(CheckQuota ‘NorthEast’ ==1)

ARITH function

It gives a numerical value from the arithmetical expression that it has as argument.

Algebraic operators allowed are:

Sum +
Subtraction –
Multiplication *
Division /

Module (or remainder) % (e.g. : 129%60 = 9)

Syntax:
ARITH(….)

Example:
Display question just if algebraic expression ([quest1]*60 + [quest2] + [quest3]*60)/60 is greater than 20.

if(ARITH(([quest1]*60 + [quest2] + [quest3]*60)/60) > 20)

Leave A Comment?