Page tree
Skip to end of metadata
Go to start of metadata

Advanced logic is used to define questions that will be asked further depending on respondents answer(s) to a particular question.

Advanced logic may be implemented using Logic expressions. These expressions include conditions combined and grouped in different ways.

The conditions check if the particular answer(s) is selected and routes respondents according to the logic rules specified by the survey owner.

In order to activate Advanced Logic in the form or survey:

  1. Click the Logic button next to the needed question on the Edit Questions page.
  2. Select Advanced Logic and click "Add New" button to create new logic expression
  3. Customize new logic rule and click "Save" button



  4. Click "Activate" button to make the rule active, once it has been created.


There are two modes for composing Advanced logic rules - Simple and Advanced. When you click Add New button, the Simple mode constructor appears by default. With its help, you can easily pick needed questions, answer options and conditions from respective drop-downs and indicate a question or a page that would be shown next to those respondents who follow rules set below.

If you would like to set up a rule based on several conditions, use the plus button to add a line with another condition and connect them with the needed operator - AND or OR. If operator AND is selected connected conditions would need to be true at the same time. OR means that respondent would fit conditions if at least one of connected conditions is true.

If your rule is based on several complex conditions, they can be connected with the help of Grouping. Grouping feature allows you to create groups of conditions within the current expression (Add Group under in a condition box) or add a new group of conditions (Add Group in the condition box). Grouping is a visible alternative to parenthesis in Advanced mode rules structure.

You can create as many logic expressions as you need and then turn them on or off depending on the current needs and requirements. For that use the Activate and Deactivate buttons under the list of saved expressions.

To switch to the Advance mode please click on the Advanced on the top left of the constructor. Using this mode you can compose rules by typing them manually.


To compose a logic expression that checks up if particular questions and answers have been selected use Question Identifiers or follow this format:

  • QX checks up if any answer has been selected in question X.
  • QX.AY checks up if answer Y has been selected in question X.
  • QX.AY.CZ checks up if answer Y has been rated in column Z in question X. (question type: 'Rate Different Items Along the Scale of Your Choice').
  • QX.CZ checks up if any answer has been selected in column Z in question X. (question type: 'Rate Different Items Along the Scale of Your Choice').
  • Surveys with enhanced offline support (Linear forms) require routing based on pages, not questions. Advanced logic in such forms is called Branching and can be set up on the Advanced Features page.
  • Keep in mind that the questions where you have applied 'Advanced logic' must come before the questions selected to follow them.
  • Logic should be the last thing applied to a question. If you modify the question in any way, make sure that your logic rules work properly.
  • Autocomplete function allows you faster and easier enter logic expressions. After entering Q, Qx.A orQx.Ay.C system will show you the list of available questions, answer options or answer columns (for 'Rate' and '3D Matrix' questions) accordingly. Picked element will be substituted by its sequence number within the survey.

Combining and Grouping

You can combine logic conditions using ANDOR and NOT operators as well as group them with parentheses ().

  • Operator AND denotes that all the combined logic conditions are fulfilled.

    Example

    If Q1.A1 AND Q1.A3 => Q4. It means that you will go to question 4 if both answer 1 and answer 3 are selected in question 1.

  • Operator OR denotes that at least one of the combined logic conditions is fulfilled.

    Example

    If Q1.A1 OR Q1.A3 => Q4. It means that you will go to question 4 if either answer 1 or answer 3 is selected in question 1.
  • Operator NOT denotes that a logic condition is not fulfilled. You can put it at the beginning of a logic condition or after AND, OR operators.

    Example

    If NOT Q1.A1 => Q4. It means that you will go to question 4 if answer 1 is not selected in question 1.
  • You can use AND, OR, NOT operators in the same logic expression simultaneously. Use parentheses to make your logic unambiguous.

    Example

    if (Q1.A1 AND Q1.A3) OR NOT Q2.A3 => Q4. It means that you will go to question 4 if either both answer 1 and answer 3 are selected in question 1 or answer 3 is not selected in question 2.
Valid symbolsExamples
Letters: Q, A, CQ1, Q1.C4, Q2.A3
Numbers: 1-9, 10 - moreQ9, Q23.A5
Dots: ...Q3.A5.C7
Operators: AND(=&&), OR (=||), NOT (=!)Q3.A1 AND Q3.A3, Q7.A3.C1 OR Q7.A3.C2, NOT Q2.A1
Parentheses: ()(Q1 AND Q3.A2) OR (Q5.A1 AND Q5.A3)

Note: to use complex expressions with double brackets, insert spaces between the brackets:
( (Q1 AND Q3.A2) OR (Q5.A1 AND Q5.A3) ) AND (Q6.A2 OR Q6.A3)
StatementsExamples
<EOF> (= end of logic expression)
<OPERAND> (= logic condition)
Q1.A2 AND - here the end of logic expression was encountered however logic condition (for example, Q1.A3) was expected.

You can apply Advanced Logic to text responses to the question of these types: Single line text with pre-format options, Multi-line text response, and Numeric Allocation as well as to Dropdown fields of the 3D Matrix type of question. List of available operators is shown below.

OperatorDescriptionExample
Logic ExpressionResults
==If text responses contain the exact line string indicated next to '==', then the logic transition is fulfilled.

This operator can also be used to refer to the record within the dropdown box of the '3D Matrix' type of question in the Qx.Ay.Cz==N format, where N is the sequence number of the item within the dropdown box that is selected by the respondent. Please note that enumeration, in this case, starts from 0, so if you need to refer to the 1st answer in the 3D Matrix dropdown, use Qx.Ay.Cz==0 condition; to the 2nd - Qx.Ay.Cz==1 and so on.
Q1.A2==CatFlower
Big Cat
Cathlene
Cat
<>If text responses do not contain the exact line string indicated next to '<>', then the logic transition is fulfilled.

This operator can also be used to refer to the record within the dropdown box of the '3D Matrix' type of question in the Qx.Ay.Cz<>N format, where N is the sequence number of the item within thedropdown box that is not selected by the respondent.
Q2.A3<>CatBig Cat
Cathlene
Cat
==LIKEIf text responses contain the line string indicated next to '==LIKE' regardless of its position in the text responses, then the logic transition is fulfilled.Q2.A3==LIKECatCat
Big Cat
Cathlene
Beautiful Flower
<>LIKEIf text responses do not contain the line string indicated next to '<>LIKE' regardless of its position in the text responses, then the logic transition is fulfilled.Q2.A3<>LIKECatCat Flower
Big Cat
Cathlene
Beautiful Flower
==RLIKE

If text responses contain the line string specified by regular expressions next to '==RLIKE' regardless of its position in the text responses, then the logic transition is fulfilled.

==RLIKERed(\s|\w)+CrossRed Bull
Cross Roads
Red fine Cross
<>RLIKEIf text responses do not contain the line string specified by regular expressions next to '<>RLIKE' regardless of its position in the text responses, then the logic transition is fulfilled.<>RLIKERed(\s|\w)+CrossRed Bull
Cross Roads
Red fine Cross
==RMATCHES==RMATCHESxxx is the same as ==RLIKE^xxx$Q1.A1==RMATCHESRed(\s|\w)+CrossRed fine Cross
Red fine Cross only
<>RMATCHES<>RMATCHESxxx is the same as <>RLIKE^xxx$Q1.A1<>RMATCHESRed(\s|\w)+CrossRed fine Cross
Red fine Cross only

 

 

 

  • Logic expressions are case-sensitive.
  • If it is needed to check text string regardless of a text case(Upper or lower case), add (?i) combination before the text and the system will ignore text case while checking the logical rule. For instance, a logical expression Q1.A1==RLIKE(?i)Ks will have the following outcome: KS,Ks,kS,ks;
  • The complex expressions with operators LIKE, MATCHES require space after themselves in order to indicate the phrase completion.

    Example

    Q1.A2==RLIKERed(\d+)Cross\1 AND Q1.A3 - is valid expression.

    Example

    Q1.A2==RLIKERed(\d+)Cross\1AND Q1.A3 - is not valid expression, as it misses the space after \1.
  • Insert space between braces and logical expressions.

    Example

    Incorrect: (Q1.A1==LIKECat OR Q1.A1==LIKEDog) AND Q1.A2==LIKEBat

    Example

    Correct: ( Q1.A1==LIKECat OR Q1.A1==LIKEDog ) AND Q1.A2==LIKEBat
  • When using the <>LIKE and <>RLIKE operators for complex expressions OR and AND operators will be inverted due to the double negation.

    Example

    (Q1.A1<>LIKECat OR Q1.A1<>LIKEDog) - the answer with both Cat and Dog text response will satisfy the expression. If only Cat or only Dog appears to be a text response, the logical expression will not be satisfied.

    Example

    (Q1.A1<>LIKECat AND Q1.A1<>LIKEDog) - the answer with both Cat and Dog text response will not satisfy the expression. If only Cat or only Dog appears to be a text response, the logical expression will be satisfied.

It is possible to create logic rules based on the answer values comparison of two different questions. You may compare:

Type of comparisonOperatorFormulaExample
fields of general formatequal(s) to, do(es) not equal toQx.Ay==[Qz.At], Qx.Ay<>[Qz.At]go to Q4 (page 3) if Q1.A1==[Q2.A1]
fields with a date or number formatting applied

equal(s) to, do(es) not equal to
less than, less than or equal to
greater than, greater than or equal to

Qx.Ay==[Qz.At], Qx.Ay<>[Qz.At]
Qx.Ay<[Qz.At], Qx.Ay<=[Qz.At]
Qx.Ay>[Qz.At], Qx.Ay>=[Qz.At]

go to Q6 (page 4) if Q3.A3==[Q4.A1]
go to Q10 (page 5) if Q5.A5<[Q6.A1]
go to Q12 (page 6) if Q7.A2>=[Q8.A1]

fields with constantsequal(s) to, do(es) not equal to
less than, less than or equal to
greater than, greater than or equal to

Qx.Ay==n, Qx.Ay<>n
Qx.Ay<n, Qx.Ay<=n
Qx.Ay>n, Qx.Ay>=n

go to Q15 (page 7) if Q9.A9==20
go to Q17 (page 8) if Q11.A2<=545
go to Q20 (page 9) if Q15.A4>6

Drill down Logic based on Advanced Logic rules

It is possible to create Drill Down logic for your survey using advanced logic rules. Drill Down, is a type of Logic setup which breaks the Form/Survey down into sections of questions according to the pages breakdown. These sections are only accessible to the respondents which are associated with a particular group based on their response. A mandatory requirement in such functionality is adding logic rules to each answer option of Multiple Selection question (of Check All that Apply or List Box type), which should determine where each group of respondents should be directed.

The table below contains the example of form/survey divided into sections. Q1 is the Multiple selection question at the beginning of the form/survey; Q6, Q11, Q17, Q22, Q27, Q32 is the last question in each section at which we should double check if some other section was selected in Q1. The first column contains the rules that specify sections' borders, others contain logic rules for correct redirecting to the appropriate questions at the end of each section.

 

Q1

Q6

Q11

Q17

Q22

Q27

Q32

Q1.A1 -> Q2
Q1.A2 -> Q7
Q1.A3 -> Q12
Q1.A4 -> Q18
Q1.A5 -> Q23
Q1.A6 -> Q28

Q1.A2 -> Q7
Q1.A3 -> Q12
Q1.A4 -> Q18
Q1.A5 -> Q23
Q1.A6 -> Q28
Q1-> Q33

Q1.A3 -> Q12
Q1.A4 -> Q18
Q1.A5 -> Q23
Q1.A6 -> Q28
Q1 -> Q33

Q1.A4 -> Q18
Q1.A5 -> Q23
Q1.A6 -> Q28
Q1 -> Q33

Q1.A5 -> Q23
Q1.A6 -> Q28
Q1 -> Q33

Q1.A6 -> Q28
Q1 -> Q33

Q1 -> Q33