The order tags article covers basic usage of the order
tag, and the Simple examples with the order tag article provides additional examples of using shorthand notations.
This article provides advanced examples for applying explicit order strings and using independent variables.
Additional examples
Ordering with independent variables
For cases requiring specific order assignments, the order
tag can accept a variable as input. This allows logic like cvalue
or selectby
to control the order.
Note, the variable containing the order must be populated with data before it can be used.
Open-end variables
To define an order for a type: text
variable, put the numeric string in the variable using cvalue
and surround the string with single quotes. In the example below, the Q1TO5ORDERVAR variable assigns anyone who selects option 1 at Q1 the value '1, 2, 3, 4, 5', while those who select option 2 at Q1 are assigned '5, 4, 3, 2, 1'. Then, the order
tag will use the value stored at Q1TO5ORDERVAR as its input.
1. Please select the option order:
type: radio
1. Increase on the left
2. Decrease on the left
1TO5ORDERVAR. Ordering Variable
type: text
invisible: y
cvalue: <<END
if (anyChecked($Q1,1)) {'1,2,3,4,5'}
else {'5,4,3,2,1'}
END
2. What do you expect will happen in the next five years?
type: radio
order: $Q1TO5ORDERVAR
1. My spend will greatly increase
2. My spend will moderately increase
3. My spend will stay the same
4. My spend will moderately decrease
5. My spend will greatly decrease
Closed-end variables
In the following example, Q5ORDERVAR is a radio variable that alternates between sequential and reverse orderings for positions 1, 2, 3, 4, and 5. The selectby: counts
tag ensures that half of the respondents see the options in increasing order, while the other half sees them in decreasing order.
5ORDERVAR. Ordering Variable
type: radio
selectby: counts
1. 1,2,3,4,5
2. 5,4,3,2,1
5. What do you expect will happen in the next five years?
type: radio
order: $Q5ORDERVAR
1. My spend will greatly increase
2. My spend will moderately increase
3. My spend will stay the same
4. My spend will moderately decrease
5. My spend will greatly decrease
Ordering with the order() method
When using an independent variable and needing ranges or square brackets []
for randomization, use the order()
method. This method supports ranges and brackets, but does not support anchors ($
, ^
) or wildcards (*
).
In the example below, options 1–3 are randomized, while option 4 remains last.
ORDERVAR.
invisible: y
type: text
cvalue: order('[1..3],4')
In this next example, Q8ORDER selects option 1 or 2, to assign either an ascending or descending order. If Q8ORDER = 2, Q8ORD assigns the order '5, 4, 3, 2, 1'. Otherwise, Q8ORD assigns the order '1, 2, 3, 4, 5'. The order
tag at Q8 then receives either of these numeric strings as the input.
8ORDER. Q8 Likert scale order
type: coded single select
selectby: counts
1. Ascending (Not at all likely -> Very likely)
2. Descending (Very likely -> Not at all likely)
8ORD. Q8 Likert scale order
type: text
invisible: y
cvalue: order( $Q8ORDER == 2 ? '(5..1)' : '(1..5)' )
chapter: logic
8. How likely are you to purchase this brand?
type: radio
order: $Q8ORD
1. Not at all likely
2. Somewhat likely
3. Neutral
4. Somewhat likely
5. Very likely
Randomizing sets of options while keeping certain options together
Explicit order strings are highly flexible. In the example below, options 1, 2, and 3 must stay together, but their order can be randomized. Similarly, options 4 and 5 must stay together, with their order also randomized. Finally, the groups themselves (1-3, 4-5, and 6) are randomized.
3A. Please select one.
type: radio
order: [[1,2,3],[4,5],6]
optsfrom: series[1..6]
Randomizing sets while anchoring a middle point
Building on the previous example, we can anchor a midpoint while randomizing groups separately. Here, the first two sets are randomized within their groups and between each other, but row 99 remains fixed in the fifth position.
11. How much do you agree/ disagree with each of the following statements?
instructions: Select one response per statement.
type: radio table
fail if: anyChecked($Q11R99) and noneChecked($Q11R99,4)
1. Strongly disagree
2. Disagree
3. Somewhat disagree
4. Somewhat agree
5. Agree
6. Strongly agree
rows:
order: [[1..4],^5,[6..9]]
1. I prioritize taking care of my face since it's the first thing people notice
2. I enjoy discovering beauty brands on social media
3. I will pay more for a product that has "clean" ingredients
4. I will pay more for products that align with my values
99. For quality purposes, please select 'Somewhat Agree'
5. Good value for money is a top priority for me
6. I am usually the first one to try new beauty products
7. I typically combine products from different beauty brands
8. I look for products that "cure" my skin concerns (e.g., eczema, rosacea, acne)
Comments
0 comments
Please sign in to leave a comment.