logo SmartSurvey / Scripting Docs
Back to Docs

Built-in Functions

All built-in scripting functions available in expressions, conditions, and validation rules. Use them to inspect response values, calculate totals, extract text, and read system state.

19
Functions
1 numberofresponse[Qx] Count
Returns the number of options selected in a multiple-response or grid question. For *MR this is the count of checked options. For grid questions it counts filled rows.
2 totalof[Qx] Count
Returns the count of filled (non-empty) entries in a list-numeric or numeric-total question. Differs from sumof[] which adds the values — totalof[] counts the entries.
3 valueof[Qx.n] Value
Returns the numeric response value at a specific position within a grid, ranking, or list-numeric question. The index n refers to the row or item code (1-based).
4 modof[Qx,n] Arithmetic
Returns the modulus (remainder) of dividing the response of Qx by n. Useful for sampling patterns (every nth respondent) or rotation logic.
5 sumof[Qx] Arithmetic
Returns the arithmetic sum of all numeric entries in a list-numeric or total question. Use to check whether total spend, scores, or allocations meet a threshold.
6 substrof[Qx,start,length] String
Extracts a substring from an open-text response. Start is 0-based; length is the number of characters to extract.
7 lengthof[Qx] String
Returns the character count of a text response. Use to enforce minimum or maximum length requirements or to check whether the respondent entered anything.
8 datevalueof[Qx,component] Date/Time
Extracts a specific component (year, month, or day) from a date question response. The date is stored internally as YYYYMMDD; this function returns the requested part as an integer.
9 timediffof[Qa,Qb] Date/Time
Returns the difference in minutes between two time question responses (Qb − Qa). Used to measure interview duration by placing *TIME questions at the start and end of the questionnaire.
10 subtractof[Qa,Qb] Arithmetic
Returns the result of subtracting the response of Qb from the response of Qa (Qa minus Qb). Use for difference calculations between two numeric questions.
11 multiplyof[Qa,Qb] Arithmetic
Returns the product of multiplying two numeric question responses. Use for weighted scores or derived metrics such as quantity × price.
12 divideof[Qa,Qb] Arithmetic
Returns the quotient of dividing the response of Qa by the response of Qb. Use for ratio calculations between two numeric questions.
13 maxvalueof[Qx] Value
Returns the maximum value across all entries in a grid or multi-entry numeric question. Use to find the highest rating or score given by the respondent across all rows.
14 maxvalueindexof[Qx] Value
Returns the 1-based row index of the entry with the highest value in a grid or multi-entry question. Use to identify which item received the highest rating.
15 stringof[Qx] String
Returns the label text of the selected option for a single-response question. Use when you need to compare or display the actual option label rather than its numeric code.
16 useridof[] System
Returns the unique identifier of the currently logged-in field interviewer (FI). Use for FI-specific routing, quota management, or audit conditions.
17 languageof[] System
Returns the current survey language code. Use to show language-specific content or route respondents to different question sets based on their language preference.
18 timeof[] System
Returns the current system time as an integer in HHMM format (e.g., 1430 for 2:30 PM). Use for time-of-day routing or to enforce interview time windows.
19 dateof[] System
Returns the current system date as an integer in YYYYMMDD format (e.g., 20260904 for September 4, 2026). Use for date-based routing or fieldwork period checks.
No matches found