Syntax Guide: List questions

November 28, 2016

List questions are recorded as Tuple<decimal, string> data type.

Each item in a list question response consists of two elements. One is the item number, and the other is the accompanying text. For example, in the list question displayed. “Paul Smith” is the text element (Item2) and “2” is the number(Item1).

List of household members =
[
{1, “Mary Smith”}
{2, “Paul Smith”}
{3, “Richard Smith”}
]
 

 The following functions can be used in conditions for list questions:

  • Length.Checks the number of items listed​
  • Item2 . Refers to the text element of an item listed in a list question

 

Length

Description

 Checks the number of items listed. 
 

Syntax 

varList.Length

This function checks the number of items recorded in a list question (varList).
 

Example 1

Assume that there is a question asking for the number of household members (hholdNum). Elsewhere, in the questionnaire there is a question asking for a list of all household members(hholdList). You want to check to make sure the answers given in the list question are consistent with the previous question.
 

self==hholdNum

 
Or alternatively use the variable name:
 

hholdList.Length == hholdNum

 
 

Item2

Description

Refers to the text element of an item listed in a list question.
 

Syntax

This feature must be used in a more complex expression. Refer to example 1 below for more information. 
 

Example 1

Suppose you want to make sure that in a list question (hhold_list) recording the list of household members the text element meaning the name being recorded is at least 5 characters long.
 
For this check, the validation condition would be:
 

hhold_list.All(x=>x.Item2.Length>=5)