The showcolumntotal
(SCT) tag works with numeric input tables to sum a column and add a "Total" row at the bottom of the table.
Try it!
Details
- To enable the SCT row on a numeric table, add
showcolumntotal: y
to the table's code. Additional tags can be included to specify the text, size, total, and message. - SCT rows can be compactly programmed in a single line of code that specifies the Total row text, and optional decorators for the text and message as shown above in T1A. For example:
showcolumntotal: Total % {total: 100} {message: Your total must equal 100%.}
. - The "Total" row creates a data location in the reporting field tree, labeled QxRSCT, where 'x' represents the question ID.
- The system class add_to_100_percent can be used as a shortcut for programming "sum-to-100 tables" and is particularly useful for creating SCT tables in IntelliBuilder.
- When an SCT table uses options selected in a previous question, it is possible to autocode and skip the table if only a single selection is made in the previous question. See example below.
Tags
showcolumntotal tags and decorators
The showcolumntotal
tag can be combined with other related tags or decorators to further modify how the text field is displayed or validated. When used as decorators, the "sct" portion of the tag can be dropped.
Tag | Decorator | Description |
showcolumntotal (alias sct ) |
N/A | Adds a "Total" row at the bottom of the table which keeps a running total of the column's sum. |
scttext |
text |
Defines custom text for the SCT row text. The default text is "Total". |
sctsize |
size |
Defines the size of the field (in ems) that displays the total. |
scttotal |
total |
Defines and validates the desired total value of all rows. This can be a number, a range, or a logical statement. |
sctmessage |
message |
Defines a custom error message for the SCT response. The default message is 'Total must equal <scttotal value>'. Must be used with the |
Commonly used tags
The following tags are frequently used with showcolumntotal
.
Tag | Description |
datatype |
Defines the type of input accepted for a response. Frequently used datatypes include: 'number', 'whole', 'integer', and 'decimals'. |
ifnotset |
Specifies a default response that is used to autofill any empty text fields. When used for SCT questions, often Include |
(alias |
Specifies instructional text to guide the respondent. |
(alias |
Sets the maximum length of text that can be entered in the text field. |
mode: tiled
|
Creates a numeric entry table with "plus" and "minus" buttons to increase or decrease the value in the text field. Responses may also be manually inputted in the text fields. |
postfix |
Specifies text to be displayed after the text field. |
prefix |
Specifies text to be displayed before the text field. |
range |
Defines and validates a numeric range. |
required |
Accepts 'y' and 'n' inputs; if set to 'n', allows respondents to not provide a response for each question-row. |
size |
Defines the size (width) of the text field in ems. This tag can be applied to any text question type to override the system defaults. |
Note: Although ifblank
can be used with SCT tables to autofill fields that are left blank, it is recommended to instead use ifnotset
, especially in the case of hidden variables, as ifblank
only populates responses for visible variables. This is especially important in the case of autocoded responses.
Additional examples
The examples below all focus on single-line definitions of showcolumntotal
.
Defining totals with logic operators
Logical operators '<' and '>' can be used with '=' to define an acceptable range for the total. In addition, by including ifnotset: 0
with required: n
, any cell left blank will be autocoded to '0'.
Setting totals defined on a variable's input
In addition to using fixed values, scttotal
will also accept responses from previous questions. In the example below, T3A uses the respondent's input from Q3 as its scttotal
.
Displaying SCT tables as tiled tables
Tiled tables are numeric entry tables that display buttons to increase or decrease the value for each text field. To create a tiled table, add mode: tiled
to the table's code.
The step
tag can also be included to specify the amount each click will increase or decrease the response value. If step
is not included, each click will increase or decrease the value by 1.
Autocoding single row SCT tables
When an SCT table uses options selected in a previous question, it is possible to autocode and skip the table if only a single selection is made in the previous question. Selecting only a single color in Q8 automatically codes that color's corresponding table input to '100' while setting the non-selected colors to '0' due to the inclusion of ifnotset: 0
.
The showtext
has been included to demonstrate how the autocoding works in reports.
Comments
0 comments
Please sign in to leave a comment.