Popular Help Content
Repeat groups can have multiple questions with the same path (ex. /data/child_repeat/name). For this reason, special functions are required when writing logic within a repeat group.
The Parent Function: (..)
Using the parent function (..) allows access the parent of the current question. For example, if writing logic for the question "What is Your Name?", typing (..) will access the /data/child_repeat in logic which can then be used to access another question within the same repeat.
Use Case: Writing logic between questions in the repeat.
Example: ../child_dob_known = 'yes' will prompt the user to enter a child's birth date only if it's known.
Use Case: Display the value of another question in the label.
Example: <output value="../name" can display the data within the <outputvalue="/data/child_repeat/name" /> string
Note: If there are groups within a repeat, (..) may need to be repeated multiple times (I.e., ../../age).
The Position Function: position( )
In a hidden value, the position function (position ()) placed in a calculate condition will return the position of a question in a repeat group (i.e., first, second). The position function is zero-indexed meaning that numbering starts with zero (0) and continues.
❗Limitation: Using the position function may cause inconsistent behavior with nested elements and conditional usage. This issue can be avoided by using the position function in the default value of a question instead of in the calculate condition.
The Current Function: current( )
The current function (current( )) will return a relative value to questions inside a repeat group which can be used for any predicate filter that makes use of square brackets [ ].
Paths can point to multiple questions so special functions must be used to access specific repeated values.
Access a Question by Count:
Accesses a specific question (ex. Question 2 in a group) using square brackets.
Example: /data/child_repeat/name will access the name of the first repeated child.
Note: This function can only be applied to text-based references and does not apply to Easy References.
Find the Number of Times a Question is Repeated: (count(question_path)
Returns the number of times a question is repeated.
Example: count(/data/child_repeat) will return the number of times a repeat group was repeated.
Filtering by Question Answer
Accesses a specific question based on an answer provided in a repeat group by using a filter in square brackets.