For more complex or advanced table scenarios, such as multicolumn tables with varying question types or tables that require advanced functions, Survey Programmers (SPs) should use the start table
widget.
Try it!
To create a an advanced table, you need to:
- Begin with the
start table
widget. The input is the table ID. - Apply the
intro
tag to provide the question text. - Apply the
type
tag with the desired input. - Add rows and/or columns.
- Provide a list of answer options (for closed-ended tables only).
- Add the
end table
tag after all other tags.
Tip! Although start table
can be used for any table design, question-style syntax is recommended in simpler tables.
Details
- Answer options, rows, and columns can be created with inline lists (within the table's code like T1 above) or pulled in from set lists (standalone lists), derived lists (from another question), or spreadsheets.
- The
options
tag is optional when including inline options. - When using an external list, a listcall tag such as
optsfrom
,rowsfrom
, orcolsfrom
is required to reference the list. - The
rows
,columns
,rowsfrom
, andcolsfrom
tags support heredoc formatting if desired. -
Vertical scale ("vscale") tables can be created with
start table
if need be. - Include a double hyphen '--' to define individual columns in a multicolumn table.
Tags
Common table tags
In addition to the type
tag, the following tags are frequently used with start table
.
Tag | Description |
|
Specifies the column elements in a table.
|
dta |
Creates an opt-out ("decline to answer") option for the entire table. |
dta col and dta row |
Creates an opt-out column or opt-out row, respectively. |
(alias |
Specifies instructions to guide the respondent. |
|
Specifies the question text. |
|
Specifies the answer options in a closed-ended table. If listing options inline, the |
|
Specifies the row elements in a table where the rows are the questions. |
(alias |
Creates a running total of all answers in a given column. |
vscale: y |
Allows respondents to select options for each column instead of each row. vscale: y is only for use with radio and checkbox tables. |
Tip! For a list of table formatting and header tags, see Table formatting and display options and Table headers.
Advanced table tags
Whereas the table above shows tags that actually can be applied to both simple and advanced tables, the following tags can only be used with the start table
widget.
Tag | Description |
-- |
Separates table columns so that each column of questions can be defined differently. This is especially useful for columns that vary in response type (radio, checkbox, text, etc.). |
colid |
Assigns an alphanumeric ID to the table column. If the tag is not included, the columns will default to being assigned numeric values in sequential order (1, 2, etc.). |
enablewhen |
Enables or disables a question or table column when a specified condition is true. |
(alias |
Defines validation conditions for a question or table. The validate tag accepts a condition as input, followed by the message tag and message text in curly brackets — e.g., validate: anyChecked([value],1,2) {message: Select option 1 or 2 } . |
row validate |
Defines validation conditions for the rows within a table. The row validate tag accepts a condition as input, followed by the message decorator and message text in curly brackets — e.g., row validate: countChecked($Q10R[id]) <= 2 { message: Select no more than 2 attributes for [text].} . |
(alias |
Defines validation conditions for the columns within a table. The column validate tag accepts a condition as input, followed by the message decorator and message text in curly brackets — e.g., column validate: countChecked($Q11C[id]) <= 2 { message: Select no more than 2 attributes for [text]. } . |
Multicolumn tables
To build a multicolumn table (a.k.a., "multitype" or "mixed type" table), some tags must be placed at the table's root, and other tags must be placed on the columns or rows. The best way to remember the structure is "establish the root before you describe the branches."
- At a minimum, a multicolumn table requires that the rows are defined at the root.
- Tags and other descriptors for the whole table must be included at the beginning (on the root).
- Options and types can be defined at the root or the column level.
- It is also possible to set a global type at the table's root, and then redefine or override the type at a column or row as shown in the intro example.
Defining the table type on each column
set list: BRANDS
1. Brand A
2. Brand B
3. Brand C
set list: YES_NO
1. Yes
2. No
set list: QUALITIES
1. Good value
2. Dependable
3. Good quality
99. None of these {exclusive: y}
start table: 2
intro: What are your thoughts on the following brands?
rowsfrom: BRANDS
--
heading: Would recommend?
optsfrom: YES_NO
type: radio
--
heading: Qualities associated with brand
optsfrom: QUALITIES
type: checkbox
end table
Additional examples
Contact information table with varying input types
When contact information is required for a survey, you can create single column tables where each row requires a different input type. Each row-question is defined by including a line space between rows and specifying the question-type and options per row.
Note: Questions with datatype: phone
and datatype: email
are encrypted by default. At this time, encrypt: y
cannot be added to individual table rows, but if added to the table root, each applicable item will be encrypted.
Table with opt-out column
The following example asks respondents to provide a text description of a list of products. In case the respondent is unfamiliar with a product, a second column is created for them to opt-out for that product.
The enablewhen
tag uses RID syntax so that, if the 'Unfamiliar' option is selected, the text field in Column 1 will be disabled for that product. To re-enable the text field for a row, simply uncheck the cell in the opt-out column.
Note that if need be, you can also create simpler opt-out columns or opt-out rows in text tables via the dta col
and dta row
tags, respectively.
Enabling columns based on previous responses
The showif
tag can be applied to column definitions to determine whether a column should be displayed. In T5, Column 1 and Column 3 are displayed based on the responses to Q4A and Q4B.
Comments
0 comments
Please sign in to leave a comment.