The functions described in this part of the documentation can be used on ranking questions and multi questions with the "Capture Order” property set. These questions will, for each answer list item, store an integer which represents the rank it was given (for example ranked as number 1) or in which order it was selected (selected 1st). A few functions are provided to easily retrieve the element that was selected first etc.
Figure 1 - Properties tab
Note: The Capture Order property is only available in surveys using the Optimized database.
First
This function is used to return the first category selected for multi choice questions with the capture order property, or the category ranked as 1st for a ranking question.
First(qid)First returns the code or label, depending on the context, of the first selected or ranked as number 1 answer category for the specified question ID qid. Label will be returned in text piping mode (within ^s), code elsewhere.
This function can only be used on ranking questions and multi's that have the capture order property enabled. It is not applicable to other multis.
Figure 2 - First function in use
#
Figure 3 - First function setup
If these responses were given in the order ITV1, BBC1, Channel 5, we would get the following result from using First():
Figure 4 - First function result
Nth
This function returns the nth category selected for a multi choice question with the capture order property, or the category ranked as the nth for a ranking question.
Nth(qid,position)Nth returns the code or label, depending on the context, of the answer category in the position specified for the specified question ID. Label will be returned in text piping mode (within ^s), code elsewhere.
Nth(“q1”,1) will return the same value as First(“q1”). This function can only be used on ranking questions or multi's that have the capture order property enabled. It is not applicable to other multis.
Figure 5 - Nth function in use
Figure 6 - Nth function setup
If these responses were given in the order ITV1, BBC1, Channel 5, we would get the following result by using Nth():
Figure 7 - Nth function result
AnswerOrder
This function is used to return an array of codes in the order selected for a multi choice question, or in the order ranked for a ranking question.
AnswerOrder(qid)AnswerOrder returns the codes of the answers supplied in the order they were selected or ranked for the specified question ID. The primary purpose of this function is to make it easy for users to retrieve the selected answer codes without having to use the Nth() function and loop through the answer list multiple times, which would result in poor script and server performance in the event of a very long answer list.
This function can only be used on ranking questions or multi's that have the capture order property enabled, it is not applicable to other multis.