Crosslists combine all possible permutations of two or more lists into a single list.
set list: CUSTOMER
1. Customer
2. Non-customer
setlist: CONCEPT
1. Concept A
2. Concept B
3. Concept C
setlist: CUST_CON
crosslists: CUSTOMER, CONCEPT
Details
- To create a crosslist, use a
setlist
widget with thecrosslists
tag and specify which lists will be used to define the new, combined list, separated by a comma. - The number of items that a crosslist will have can be determined by multiplying together the number of items in each list being crossed.
- Crosslist option IDs are created by concatenating the original list IDs. The default separator for each concatenated option ID is an underscore, and a comma for each new option text. To override these defaults, use the
crosslistidseparator
andcrosslisttextseparator
tags. - All conditions,
desc
decorators, and option decorator data are also preserved, so they can be used by any questions or variables which reference the crosslist. - Crosslists support the ability to include and exclude options from the lists being crossed, (e.g.,
crosslists: PURCH, AGE-[1,2]
). - The crosslist setlist must be defined after its component lists in the survey source.
- Crosslist quotas are displayed in a grid in the Quotas applet, where the first list is used for the rows and the remaining list(s) are used for the columns.
Caution! Be cautious when creating large crosslists, as they can lead to complex and very large data structures.
Determining list order
Crosslists display combinations in a defined order. Each element from the first list is paired sequentially with all elements of the second list, listed in numerical order by the element IDs. This pattern continues until all elements of the first list have been paired with all elements of the other list(s). For example, the code above produces the following list:
1_1. Customer, Concept A
1_2. Customer, Concept B
1_3. Customer, Concept C
2_1. Non-customer, Concept A
2_2. Non-customer, Concept B
2_3. Non-customer, Concept C
Additional examples
Modifying the ID and text separators
The crosslistidseparator
tag alters how IDs in a crosslist are separated in the data. By default, the option ID from the 'CUST_CON' list used above is 1_1
. However, applying crosslistidseparator:
would change the ID format to 11
.
Similarly, the crosslisttextseparator
tag alters how option (or desc
decorator) texts are separated in the data. By default, the option text from the 'CUST_CON' list appears as Customer, Concept A
. Using crosslisttextseparator: ~
would change the text format to Customer~
Concept A
.
See the updated code below for the changes.
set list: CUSTOMER
1. Customer
2. Non-customer
setlist: CONCEPT
1. Concept A
2. Concept B
3. Concept C
setlist: CUST_CON
crosslists: CUSTOMER, CONCEPT
crosslistidseparator:
crosslisttextseparator:~
Tip! Apply the HTML for "non-breaking space" (
) to force a space between the first text and ~
.
Referencing question IDs instead of lists
It is possible to build crosslists from questions rather than lists. This reference to a question is called question-label shorthand. It's an abbreviated way to write a conditional statement meaning "all options selected at QX."
In the example below, AGEGENLIST uses question-label shorthand to reference Q4 and Q5. Since both of these questions are single select questions, only one option will be selected from each. The crosslist will then produce only one viable combination of options from Q4 and Q5.
The use of a crosslist in a quota is explained in the next example.
setlist: GEN 1. Man 2. Woman
3. Non-binary setlist: AGERANGES 1. 18 - 34 2. 35 - 54 3. 55 and above 4. What is your gender? type: radio optsfrom: GEN 5. What is your age? type: radio optsfrom: AGERANGES set list: AGEGENLIST crosslists: Q4, Q5 AGEGEN. QUOTA | Age-Gender type: quotas optsfrom: AGEGENLIST
Understanding crosslists and conditions
Conditions are defined using curly braces to enclose an "if statement" (e.g., {if ($Q3 >= 18 and $Q3 <= 24)}
). These conditions are carried forward and applied to each crosslist option. A common use case is nested demographic quotas, such as crossing age ranges and gender.
In the example below, the crosslist GENAGELIST
is created by crossing the lists QP1 and AGELIST.
- QP1 is question-label shorthand, discussed in the previous example. QP1 is a single select question, and only one option will be present for each respondent.
- The options in AGELIST each have a condition referencing QP2. Ultimately, only one option's condition will be true, meaning only one option will be applicable for each respondent.
The optsfrom: GENAGELIST
tag does not require any locally defined conditions because the inherited conditions from both QP1
and AGELIST
are applied to the list options. Since GENAGE
is a type: quotas
variable, it will automatically "punch" the applicable option for each respondent based on the inherited conditions.
setlist: GENLIST
1. Male
2. Female
3. Other gender identity
P1. What is your gender?
type: radio
optsfrom: GENLIST
P2. What is your age?
type: text
datatype: whole
range: 1-99
termif: ($QP2 < 18) {text: QP2 (Age: 17 or younger) }
setlist: AGELIST
18. 18 - 24 {if ($QP2 >= 18 and $QP2 <= 24)}
25. 25 - 34 {if ($QP2 >= 25 and $QP2 <= 34)}
35. 35 - 44 {if ($QP2 >= 35 and $QP2 <= 44)}
45. 45 - 54 {if ($QP2 >= 45 and $QP2 <= 54)}
55. 55 - 64 {if ($QP2 >= 55 and $QP2 <= 64)}
65. 65+ {if $QP2 >= 65}
setlist: GENAGELIST
crosslists: QP1,AGELIST
GENAGE. QUOTA |Gen-Age
type: quotas
optsfrom: GENAGELIST
Using decorator data
Additional data stored in lists with option data decorators can also be pulled into crosslists just like conditions. In the following example, a crosslist created from two lists with custom option data is referenced and displayed to the respondent.
Please scroll to see the full source code.
Referencing crosslist IDs in conditional logic
To reference a crosslist parent ID in a listcall (e.g., optsfrom
), prefix the origin list name to the id
placeholder, separated by an underscore (e.g., [LISTNAME_id]). Prefixing clarifies list references and is necessary for the software to iterate across different lists.
In the example below, crosslist BRANDS_X_FAM uses the lists BRANDS and FAMILIAR to create its combined list.
setlist: BRANDSTo reference the crosslist in conditional logic, such as on an
1. Brand X
2. Brand Y
3. Brand Z
setlist: FAMILIAR
1. Not at all familiar
2. Slightly familiar
3. Very familiar
4. Extremely familiar
setlist: BRANDS_X_FAM
crosslists: BRANDS,FAMILIAR
optsfrom
tag, use 'BRANDS_id' and 'FAMILIAR_id' as placeholders. Enclose these references in square brackets, just like the standard [id] placeholder.
optsfrom: BRANDS_X_FAM {if anyChecked($Q1R[BRANDS_id],[FAMILIAR_id])}
Here:
- 'BRANDS_id' iterates through each ID from the BRANDS list, creating the row reference.
- 'FAMILIAR_id' iterates through each ID from the FAMILIAR list, becoming the answer option.
When using question-label shorthand, reference variable names instead of list names.
In the example below, crosslist BRANDS_PRODUCTS uses variables QL1BRANDS and QL1PRODUCTS to create its combined list.
setlist: BRANDS_PRODUCTS
crosslists: QL1BRANDS,QL1PRODUCTS
Then, we could write the following:
rowsfrom: BRANDS_PRODUCTS {if anyChecked($QS14R[QL1BRANDS_id],[QL1PRODUCTS_id])}
Here:
- 'L1BRANDS_id' pulls in any ID "punched" at QL1BRANDS, creating the row reference.
- 'L1PRODUCTS_id' pulls in the IDs punched at QL1PRODUCTS, becoming the answer option.
Version Notice: This article covers features in our r9/IS Pro platform. If you're looking for information on this topic related to r8, see Crosslists.
Comments
0 comments
Please sign in to leave a comment.