The maxgroups
tag specifies the maximum number of options or quota groups that a respondent may be assigned to, provided that the respondent meets qualifying condition criteria and, in the case of a quota, the bucket is not full.
2. In which areas of medicine are you <b>board-certified</b>?
type: checkbox
instructions: Please select all that apply.
qualify if: anyChecked($Q2,6,7,9,11)
1. Allergy / Immunology
2. Dermatology
3. Endocrinology
4. Gastroenterology
5. General / Internal / Family Practice Medicine
6. Hematology / Oncology
7. Medical Oncology
8. Neurology
9. Orthopedic Surgery
10. Rheumatology
11. Orthopedic Oncology
97. Other {autoother: y; placeholder: Specify}
99. I am not board-certified in any types of medicine {exclusive: y}
2_QTA. Quotas based on Q2
type: quotas
maxgroups: 2
1. Oncology {if anyChecked($Q2,6,7,11)}
2. Surgery {if anyChecked($Q2,9)}
Details
- The
maxgroups
tag is intended for use with hidden checkbox (multiselect) variables, coded multiple select variables, and quotas. -
maxgroups
can accept a static value (e.g.,maxgroups: 2
), a dynamic value like a question reference (e.g.,maxgroups: $Q2
), or a Perl conditional statement. - Quotas are single select variables by default. Apply the
maxgroups
tag to make the quota a multiselect variable. - Hidden checkbox variables and coded multiple select variables allow respondents to be assigned to all qualifying options by default. Apply the
maxgroups
tag to limit the number of groups they can qualify for. -
Heredoc can be included with
maxgroups
to define more complex logical conditions.
Tip! The maxgroups
tag is not intended for visible questions. For respondent-facing questions, use the maxChecked
tag instead.
Additional examples
Conditioned 'maxgroups' with 'if else'
Perl "if/else" statements can be used with maxgroups
. In QSOME_ACTIVITY, respondents qualify for up to four activities if they rated Yoga (Q1B, row 7) a 4 or higher; otherwise, the limit is three. All assigned activities must also meet the condition decorator criteria.
1B. Please indicate how many times per month you do the following activities:
type: radio table
optsfrom: series[0..5]
6. 6 or more
rows:
1. Running
2. Walking
3. Lifting weights
4. Biking
5. Playing sports
6. Swimming
7. Yoga
SOME_ACTIVITY. Selects 3 or 4 Activities
type: quotas
maxgroups: if ($Q1BR7>=4) {4} else {3}
selectby: condition
optsfrom: T1B.rows {if anyChecked($Q1BR[id],2..6)}
Heredocs with 'maxgroups'
For more complex conditions, heredoc can be used within the maxgroups
tag. QRESTAURANTS uses an "if/elsif/else" statement to define conditions for when to assign each respondent to one, two, or three buckets based on their selection at Q10.
setlist: RESTAURANTS
randomize: y
1. Friendly's
2. Applebee's
3. Outback Steakhouse
4. TGI Friday's
5. Chipotle
6. Panera Bread
7. Olive Garden
10. How many chain restaurants do you visit in a typical month?
type: radio
1. 1
2. 2
3. 3 or more
RESTAURANTS. Restaurant selection
type: coded multiple select
selectby: counts
maxgroups:<<END_MG
if (anyChecked($Q10,1)) {1}
elsif (anyChecked($Q10,2)) {2}
else {3}
END_MG
optsfrom: RESTAURANT
Comments
0 comments
Please sign in to leave a comment.