Question types

Question layouts

Operators and functions

Variables

Operator Scope Meaning
${question_name} All columns except type and name indicating the answer value of the previous question, where question_name is the question’s name (i.e. the column name in sheet survey).
. constraint indicating the answer value of the current question.

Expressions

  • Expressions are formula used with operators to retrieve numbers, strings, or boolean values (True or False).

Operator

Math operators

  • Math operators only work with numbers and return numbers as the result.
  • Math operators can be used in the following columns of sheet survey:
    • constraint
    • relevant
    • required
    • calculation
    • appearance
Operator Meaning Example
+ Addition ${female} + ${male}
- Subtraction . - ${child_age}
* Multiplication ${unit_price} * ${quantity}
div Division ${total_point} div 100
mod Modulo (division remainder) ${random_number} mod 2

Warning

Empty values (that is, variables referencing unanswered questions) are actually empty strings, and will not be automatically converted to zero (0)

Comparison operators

  • Comparison operators are used to compare values. The result of a comparison is always True or False.
  • Comparison operators can be used in the following columns of sheet survey:
    • constraint
    • relevant
    • required
    • calculation
    • appearance
Operator Meaning Example
= equal to ${consent} = 1
!= not equal to ${non_smoke} != 0
> greater than ${annual} > ${monthly}
< less than ${birth_year} < ${current_year}
>= greater than or equal to ${amount} >= 0
<= less than or equal to ${age} <= 3

Warning

The relational operators (>, <, >=, <=) operators only work with numbers. Meanwhile, = and != can compare numbers or strings.

Boolean operators

  • Boolean operators combine two True or False values into a single True or False value.

  • Boolean operators can be used in the following columns of sheet survey:

    • constraint
    • relevant
    • required
    • calculation
    • appearance
Operator Meaning Example Example Result
or True if at least 1 value is True ${year} < 2000 or ${year} > 2002 True if ${year} = 1999 or less, True if ${year} = 2003 or more, False if ${year} = 2000, 2001 or 2002, where year is an integer value
and True if both 2 values are True ${year} > 2000 and ${year} < 2002 True if ${year} = 2001, False if ${year} = 2000 or less, ${year} = 2002 or more, where year is an integer value

Functions

  • Functions can be used in the following columns of sheet survey:

    • constraint
    • relevant
    • required
    • calculation
    • appearance
  • There are several kinds of functions:

Conditional functions

boolean(arg)
true(arg)
false(arg)
not(arg)
if(expression, then, else)
coalesce(arg, arg)

String functions

join(separator, variable_inside_group)
concat(arg, [, arg [, arg [...]]])
substr(string, start[, end])
string-length(string)
contains(string, substring)
starts-with(string, substring)
ends-with(string, substring)

Numeric functions

number(arg)
int(number)
round(number, digits)
pow(number)
abs(number)

Datetime functions

today()
now()
date(days)
decimal-date-time(datetime)
decimal-date-time(time)
format-date(date, format)

Returns :arg:`date` as a string formatted as defined by :arg:`format`.

The following identifiers are used in the :arg:`format` string:

%Y 4-digit year
%y 2-digit year
%m 0-padded month
%n numeric month
%b short text month (Jan, Feb, Mar…)
%d 0-padded day of month
%e day of month
%a short text day (Sun, Mon, Tue…).

Note

Month and day abbreviations are language and locale specific. If form locale can be determined, that locale will be used. Otherwise, the device locale will be used.

format-date-time(datetime, format)

The identifiers list in format-date() are available, plus the following:

%H 0-padded hour (24-hr time)
%h hour (24-hr time)
%M 0-padded minute
%S 0-padded second
%3 0-padded millisecond ticks.

Random functions

once(expression)
random()
uuid([length])