In some situations it is convenient to have multiple individual elements (numbers, texts, variables) to be combined in a single collection - an array. Once an array is created, whether the same for everyone, or different for each respondent, it can be used in many scenarios:
- Extract individual elements by their indices
- Display the whole array to the respondent, each element delimited with a comma
- Compare to another array and see if they match or not
- Do an exact search within an array. For example, you might want to find if respondent said "agree" or "yes" in any of his OE responses (previously collected into an array)
- Search for a part of text in an array. Useful for checking if respondent mentioned specific brand in his OE response, given an array of possible misspells of the brand
Syntax
|
Examples
|
Shuffle
An array can be shuffled, meaning positions of its elements get randomly redistributed. Useful when there's a need to randomize the order at which the items are shown from the pile of all possible variations. An optional modifier "max" allows limiting the length of the resulting array, so that only the specified number of random elements is returned. Syntax:
|
Reverse
An array can be reversed - the last element takes place of the first, the second last of the second first, and so on. Syntax:
|
Unique
An array can be shortened by removing all duplicates, thus ensuring that each element is unique in the resulting set. Syntax:
|
Sort
Sort an array in ascending direction. The behavior is different depending on the type of array:
Syntax:
|
Sort elements by array
Arrays can be used to impose a specific order in which elements in the survey will be shown. An array of one-based indices applied over a set of items (for example, over sub-questions of the Slider question), will instruct the system to place said items in the specified order. The location of the logic does not matter, it may be placed on any question in the survey (still, make sure the variable by which the sorting happens is initialized before the sorted question). Syntax:
|