Expression syntax
Display logic decides whether respondents see an element, and an answer condition decides whether they see an answer. get_questionnaire returns them as plain text, and returns titles and instructions as HTML. The field name tells you which reading you have:
- Plain text.
display_logicandanswers[].conditionhold an expression such asQAGE > 18 AND S5.1. - HTML.
valueon a question or message,answers[].titleandinstructions_for_respondenthold titles and instructions, with each inserted earlier answer and each condition in braces.
display_logic_for_scripting and answers[].condition_for_scripting are free text written for the team scripting the questionnaire. They follow none of the syntax below.
Operators
Section titled “Operators”| Reads as | Meaning |
|---|---|
AND |
All of |
OR |
Any of |
NOT |
Not |
= |
equals |
!= |
does not equal |
< |
is less than |
<= |
is at most |
> |
is greater than |
>= |
is at least |
+ |
plus |
- |
minus |
* |
times |
/ |
divided by |
COUNT(…) |
Number of rows |
SUM(…) |
Sum of rows |
ANY(…) |
Any row of |
ALL(…) |
Every row of |
Parentheses show grouping. An AND inside an OR is always wrapped, and so is an OR inside an AND. NOT covers the comparison after it, so NOT QAGE > 18 means NOT (QAGE > 18). Text values are double-quoted, as in "Female". Whole numbers read without a decimal point, so 18.0 reads as 18, and booleans read true or false.
The four row operators take a list, such as Q1.*.C1 or Q1.A1, Q1.A2, Q1.A3, and skip rows left unanswered. COUNT(…) is how many of them are true, so COUNT(Q1.A1, Q1.A2, Q1.A3) >= 2 means at least two of the three are chosen. SUM(…) adds their numbers. ANY(…) is true when at least one is true, and ALL(…) when every one is.
References
Section titled “References”QAGE: the respondent’s answer to that question. On a choice question it compares the text of the answer chosen. On a number question it is the number given.S5.1orQ1.A1: an answer, by question label then answer label. On a choice answer it is true when that answer is chosen, which is how screen-outs generated from an answer read. On a numeric grid row it is the number given for that row.Q1.A1.C1: the grid cell where row A1 meets column C1.Q1.*.C1is the cell in column C1 for every row.Q1.A1 (text): the text typed into the open-end box of answer A1.Q1.SUBJECT: inside a loop, the answer that the current iteration stands for..count,.fill_percentageand.score: a quota cell or a MaxDiff item, as inQ1.PEPSI.fill_percentageandQMD.PRICE.score.Q7@PEPSI.TASTE: a reference pinned to one iteration of a loop. Nested loops are joined with›, and·stands for the iteration being answered.SAMPLE.W2: true for respondents in that sample.METHODOLOGY.CATI: true for respondents on that methodology.?: stands for a question, answer or sample that the questionnaire no longer has.
Conditional titles
Section titled “Conditional titles”Titles, answer titles and instructions are HTML, and a condition inside one is written as a block:
{IF S1.1} <p>A</p> {IF S1.2} <p>B</p> {ELSE} <p>C</p> {END}Each {IF} before the single {ELSE} is an alternative, tried in order. The first whose condition holds shows, and {ELSE} shows when none does. Each branch is HTML and can hold its own {IF} … {END} block.
Inside a title, a condition is HTML-escaped, so QAGE > 18 reads {IF QAGE > 18} and a quote reads ". An inserted answer, such as {S5}, escapes <, > and &, but not quotes.
A title stored as plain text, with no expression behind it, shows its {S5} and {IF ...} to respondents exactly as written.