Expression questions

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
Returns true_value if the given condition is true and false_value if the condition is false.
Example: iif({question1} + {question2} > 20, 'high', 'low')

age

 

age(birthDate: any): number
Returns the age according to the date of birth
Example: "age({date_of_birth})"

getCurrentdate

 

getCurrentdate(): Date
Returns the current date.
Example: "GetCurrentdate()"

today

 

today(days_to_add: number): Date
Returns the current date or a date calculated using the parameter which specifies the number of days to be added to the current date.
Examples: "today()" returns todays date; "today(2)" returns day after tomorrow; "today(-1) returns yesterdays date"; etc

getDate

 

getDate(question_name: expression): Date
Returns the specified question's date value.
Example: "getDate({Birthday})"

weekday

 

weekday(date?: Date): Number
Returns the day of the week for a given date as a value from 0 (Sunday) to 6 (Saturday).
Example: "weekday({Birthday})"

day

 

day(date?: Date): Number
Returns the day of the month for a given date.
Example: "day({Birthday})"

month

 

month(date?: Date): Number
Returns the month for a given date.
Example: "month({Birthday})"

year

 

year(date?: Date): Number
Returns the year for a given date.
Example: "year({Birthday})"

diffDays

 

diffDays(date_from: any, date_to: any): number
Returns the absolute number of days between two dates.
Example: expression: "diffDays({start_date}, {end_date}) > 30"

differenceDays

 

differenceDays(date_from: any, date_to: any): number
Returns the number of days between two dates.
Example: expression: "diffDays({start_date}, {end_date}) > 30"

sum

 

sum(par1: number, par2: number, ...): number
Returns the sum of the arguments.
Example: "sum({total_one}, {total_two})"

max

 

max(question_one: number, question_two: number, ...): number
Returns the largest value from a list of the arguments
Example: "max({question_one}, {question_two})"

min

 

min(question_one: number, question_two: number, ...): number
Returns the largest value from a list of the arguments.
Example: "min({question_one}, {question_two})"

avg

 

avg(question_one: number, question_two: number, ...): number
Returns the average value of the passed arguments.
Example: "avg({question_one}, {question_two}, {question_three})"

sumInArray

 

sumInArray(question_name: expression, property_name: string): number
Returns the sum of values in a array from the question property; the question and its property are referenced by their names.
Example: "sumInArray({matrixdynamic_one}, 'total') > 1000"
;

maxInArray

 

maxInArray(question_name: expression, property_name: string): number
Returns the maximum of all values in an array specified by a property of a matrix question.
Example: "maxInArray({matrixdynamic_one}, 'quantity') > 20"

minInArray

 

minInArray(question_name: expression, property_name: string): number
Returns the minimum of all values in an array specified by a property of a matrix question.
Example: "minInArray({matrixdynamic_one}, 'quantity') > 5"

avgInArray

 

avgInArray(question_name: expression, property_name: string): number
Returns the average of all values in an array specified by a property of a matrix question.
Example: "avgInArray({matrixdynamic_one}, 'quantity') > 10"

getTextValue

 

getTextValue(question_name: string): string
Returns the text value of a questions.
Example: "getTextValue('question1') "

getTablevalue

 

getTablevalue(table_value: integer): any
Returns a data table value, when question1 is a dropdown question with choices from a data table then getTablevalue will give the value in the table. 
Example: "getTextValue({question1}) "

getUser

 

getUser(): string
Returns the username of the current user.
Example: "getUser() "

getRole

 

getRole(): string
Returns the role of the current user.
Example: "getRole() "

countInArray

 

countInArray(question_name: expression, property_name: string): number
Returns the total number of items of all values in an array specified by a property of a matrix question.
Example: "countInArray({matrixdynamic5}) > 10"

addTime

 

addTime(time1: string, time2: string): string
Adds two time values in HH:MM format (using single input time question) and returns the sum as a string in HH:MM format. Both parameters must be valid time strings with hours (0-23) and minutes (0-59).
Example: "addTime({TimeStart},{TimeEnd})" returns "04:15"

diffTimeHM

 

diffTimeHM(startTime: string, endTime: string): string
Calculates the difference between two time values in HH:MM format (using single input time question) and returns the difference as a string in HH:MM format. Both parameters must be valid time strings with hours (0-24) and minutes (0-59). Handles cases where endTime is earlier than startTime by calculating across midnight.
Example: "diffTimeHM({TimeStart
},{TimeEnd})"
Example: "diffTimeHM("23:00", "02:00")" returns "03:00"

getCurrenttime

 

getCurrenttime(): string
Returns the current system time in HH:MM:SS format. Takes no parameters.
Example: "getCurrenttime()" returns "14:30:45"

getFname

 

getFname(): string
Returns the first name of the current user, takes no parameters.
Example: "getFname()" returns "John"

getLname

 

getLname(): string
Returns the last name of the current user, takes no parameters.
Example: "getLname()" returns "Smith"

getRegtablevalue

 

getRegtablevalue(questionName: string): string
Retrieves a registration table value from the current survey registration dropdown question defined by the registration table.
Example: "getRegtablevalue("salesItem")" returns the selected dropdown question salesItem defined by the registration table salesI
tem

getRegvalue

 

getRegvalue(questionName: string): string
Retrieves a value from the current survey registration based on the question name.
Example: "getRegvalue("quantity")" returns the value of the quantity question in the registration

getRole

 

getRole(): string
Returns the role of the current mobile user, takes no parameters.
Example: "getRole()" returns role number of the mobile user

isanswered

 

isanswered(questionName: string, valueIfEmpty: any, valueIfNotEmpty: any): any
Checks if a survey question is answered. If the question is empty, returns the first value; if answered, returns the second value.
Example: "isanswered("feedback_comment", 0, 1)"

latitude

 

latitude(coordObject: object): string
Extracts the latitude value from a GPS coordinate question. Returns an empty string if the coordinate object is empty or invalid.
Example: "latitude({GPS question})"

longitude

 

longitude(coordObject: object): string
Extracts the longitude value from a GPS coordinate question. Returns an empty string if the coordinate object is empty or invalid.
Example: "longitude({GPS question})" 

round

 

round(value: number, decimals: integer): string
Rounds a number to the specified number of decimal places. Both parameters must be provided; decimals must be a non-negative integer.
Example: "round(3.14159, 2)" returns "3.14"
Example: "round(7.456, 1)" returns "7.5"

sumExternal

 

sumExternal(questionnaireName: string, questionName: string): string
Calculates the sum of values from external survey data based on the questionnaire name and question name in the current survey. Example: "sumExternal("inventory", "quantity")" returns "150"

getDistancebetweencoords

 

getDistancebetweencoords(coord1: object or string, coord2: object or string): string
Calculates the distance in kilometers between two GPS coordinate questions results rounded to 1 decimal place.
Example: "getDistancebetweencoords({GPS question one}, {GPS question one})" 

 

 

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?

 

© Denkami 2026 | 18 Kapumpe Rd, Lusaka, Zambia | +260 962 401 869 | admin@denkami.com