With expression questions you can calculate a value based on previously answered questions. This tutorial will explain how to use the expressions questioon and inbuild function
Using question results
With an expression you use previously answered questions results to get a new result, to access these results you can use:
{questionname} | Access the value of a single input question |
{dynamicpanelname[index].questionname} | Access the question value inside the panel dynamic, where index is zero-based |
{matrix[index].columnname} | Access the question value for matrix dynamic, where index is zero-based |
{row.columnname} | Access the row value in a matrix multiple choice expression question |
{questionname-total.columnname} | Access the total value in a matrix multiple choice question |
Using functions
The format for using function is: functionName(Argument1, Argument2, .... , ArgumentN), and agrument can also be a function, explained in the section below.
iif
|
iif(condition: expression, true_value: any, false_value: any): any |
age
|
age(birthDate: any): number |
currentDate
|
currentDate(): Date |
today
|
today(days_to_add: number): Date |
getDate
|
getDate(question_name: expression): Date |
weekday
|
weekday(date?: Date): Number |
day
|
day(date?: Date): Number |
month
|
month(date?: Date): Number |
year
|
year(date?: Date): Number |
diffDays
|
diffDays(date_from: any, date_to: any): number |
differenceDays
|
differenceDays(date_from: any, date_to: any): number |
sum
|
sum(par1: number, par2: number, ...): number |
max
|
max(question_one: number, question_two: number, ...): number |
min
|
min(question_one: number, question_two: number, ...): number |
avg
|
avg(question_one: number, question_two: number, ...): number |
sumInArray
|
sumInArray(question_name: expression, property_name: string): number |
maxInArray
|
maxInArray(question_name: expression, property_name: string): number |
minInArray
|
minInArray(question_name: expression, property_name: string): number |
avgInArray
|
avgInArray(question_name: expression, property_name: string): number |
displayValue
|
getTextValue(question_name: string): string |
getUser
|
getUser(): string |
getRole
|
getRole(): string |
countInArray
|
countInArray(question_name: expression, property_name: string): number |
countAnswers
|
countAnswers(survey_name.questionnaire_name.question_name: string, question_answer: string or expression): number Example: "counAnswer("stockcontrol.registration.item", {stockitem})" When using the registration of the survey |
Boolean expressions
Boolean expressions return a true or false value, some examples are shown below:
"{age} >= 21" | Returns true if the age is 21 or higher |
"{age} >= 21 and {age} < 65" | Returns true if the age is 21 or larger and smaller than 65 |
"!({age} >= 21 and {age} < 65)" | Returns false if the age is 21 or larger and smaller than 65 |
"{name} = notempty" | Returns true if the name question is not empty |
"{name} = empty" | Returns true if the name question is empty |
"{country} = ['France','Spain']" | Returns true if the country question selects only France and Spain (checkbox) |
"{country} = contains 'Spain'" | Returns true if the country question selects at least Spain (checkbox) |
Operators:
AND | Logic AND function, both conditions need to be true |
OR | Logic OR function, at least one conditions needs to be true |
! | Logic NOT function, inverse the result |
notempty | Is question not empty? |
empty | Is question empty? |
contains | Does question contain a value? |