Skip to main content
Skip table of contents

Advanced Logic

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:

  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 rule's 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: 'Rating Scale').

  • QX.CZ checks up if any answer has been selected in column Z in question X. (question type: 'Rating Scale').

  • Surveys with enhanced offline support (Linear forms) require routing based on pages, not questions. Advanced logic in such forms is called Branchingand 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 or Qx.Ay.C system will show you the list of available questions, answer options or answer columns (for 'Rate' and '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 ().

 Logic operators:

  • 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 symbols in logic expressions

Valid symbols

Examples

Letters: Q, A, C

Q1, Q1.C4, Q2.A3

Numbers: 1-9, 10 - more

Q9, 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)

 Conventional statements in alert messages

Statements

Examples

<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.

 Advanced Logic with text

You can apply Advanced Logic to text responses to the question of these types: Single line text, Multi-line text, and Numeric Allocation as well as to Dropdown fields of the Matrixtype of question.

List of available operators is shown below.

Operator

Description

Example

Logic Expression

Results

==

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==Cat

Flower
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<>Cat

Big Cat
Cathlene
Cat

==LIKE

If 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==LIKECat

Cat
Big Cat
Cathlene
Beautiful Flower

<>LIKE

If 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<>LIKECat

Cat 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)+Cross

Red Bull
Cross Roads
Red fine Cross

<>RLIKE

If 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)+Cross

Red Bull
Cross Roads
Red fine Cross

==RMATCHES

==RMATCHESxxx is the same as ==RLIKE^xxx$

Q1.A1==RMATCHESRed(\s|\w)+Cross

Red fine Cross
Red fine Cross only

<>RMATCHES

<>RMATCHESxxx is the same as <>RLIKE^xxx$

Q1.A1<>RMATCHESRed(\s|\w)+Cross

Red 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.

  • RMATCHES works differently online and in the offline apps (iOS, Android, Windows). To make it work in the apps, you should wrap the regexp with ^()$

ℹ️ Example

Q1.A1==RMATCHES(^([0-9]|1[0-9]|2[0-9]|3[0-9])$)

 Advanced logic with question answers

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

Type of comparison

Operator

Formula

Example

fields of general format

equal(s) to, do(es) not equal to

Qx.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 toless 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 constants

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

Qx.Ay==n, Qx.Ay<>nQx.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

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.