The listUnique
function iterates through a list, checking whether each row-question in a table contains a distinct response. If duplicate a response is found an error message is shown.
set list: BRANDS
1. Brand 1
2. Brand 2
3. Brand 3
3. What is the first word that comes to mind for each brand?
instruct: Please enter a different word for each brand.
type: text table
required: n
size: 30
rowsfrom: BRANDS
validation: listUnique(BRANDS; $Q3R[id]) {message: Please enter a different word for each brand.}
Tip! Not sure which list function is best suited for your needs? Review all list functions here.
Details
-
In its most basic form,
listUnique
accepts two inputs: a list name and a field reference constructed with the '[id]' placeholder. - Options can be filtered in or out of the list with inclusion/exclusion syntax.
- This function is particularly helpful for verifying that text inputs and autoothers do not contain identical responses. It automatically compares the fields that have a response and ignores fields that have not been answered.
Additional examples
Validating autoother options
You can also ensure text entered in autoother ("other specify") fields is unique. In this example, the list includes the previous BRANDS list used in the example above, plus three new autoothers. To validate only the autoother responses, we use inclusion syntax to specify the option IDs '[971..973]', and to reference the autoother text field, we use the format 'QX_[id]_OTH', where 'X' is the question number, '[id]' is the option ID, and '_OTH' indicates the autoother field.
Ensuring a closed-ended table is unique
Although less common, you can also force every row in a closed-ended table to have a unique response. In the table below, every brand is forced to select a different option.
Comments
0 comments
Please sign in to leave a comment.