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
orFalse
).
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
orFalse
.  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
orFalse
values into a singleTrue
orFalse
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])¶

stringlength(string)

contains
(string, substring)¶

startswith(string, substring)

endswith(string, substring)
Datetime functions¶

today
()¶

now
()¶

date
(days)¶

decimaldatetime(datetime)

decimaldatetime(time)

formatdate(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 4digit year %y 2digit year %m 0padded month %n numeric month %b short text month (Jan, Feb, Mar…) %d 0padded 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.

formatdatetime(datetime, format)
The identifiers list in
formatdate()
are available, plus the following:%H 0padded hour (24hr time) %h hour (24hr time) %M 0padded minute %S 0padded second %3 0padded millisecond ticks.