The show column total
tag works with numeric input tables to sum a column and add a "total" row at the bottom of the table.
Details
- To enable a total row in a numeric table, add
show column total: y
to the table widget. The default text is "Total," but you can customize it by replacing 'y' with the desired text, e.g.,show column total: Total %
. - Total rows can be compactly programmed in a single line of code by using decorators to define the total amount and message to display.
- If using decorators,
show column total
requires a text input, e.g.,show column total: Total
. - The total row includes built-in validation to enforce the required total.
- A multi-line approach with additional tags instead of decorators is also supported.
- The total row creates a data location in the reporting field tree, labeled QxRSCT, where 'x' is the question ID.
- When an table uses options selected in a previous question, it is possible to autocode and skip the table if only one selection is made in the previous question.
- 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 these tables in IntelliBuilder.
Tags
'show column total' tags and decorators
The show column total
tag can be combined with other related tags or decorators to further modify how the text field is displayed or validated. To apply a decorator, omit the word 'sct' from the tag and use the remaining text as the decorator label.
Tag | Decorator | Description |
show column total (alias sct ) |
N/A | Adds a "Total" row at the bottom of the table which keeps a running total of the column's sum. |
sct message |
message |
Customizes the error message text. The default message is 'Total must equal <sct total value>'. Must be used with |
sct size |
size |
Defines the size of the field (in ems) that displays the total. |
sct text |
text |
Customizes the text for the total row. The default text is "Total." |
sct total |
total |
Specifies the desired total value of all rows. This can be a number, a range, or a logical statement. |
Commonly used tags
The following tags are frequently used with show column total
.
Tag | Description |
datatype |
Defines the type of input accepted for a response. Frequently used datatypes include: 'number', 'whole', 'integer', and 'decimals'. |
if not set |
Specifies a default response that is used to autofill any rows left unfilled. |
Provides instructional text to guide the respondent. | |
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' (default) and 'n' inputs; if set to 'n', allows respondents to proceed without answering every 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. |
Additional examples
The examples below all focus on single-line definitions of show column total
with the total
decorator. All of the examples below also apply to the multi-line approach with the sct total
tag.
Setting totals with logical operators
Logical operators '<' and '>' can be used with '=' to set a range for the total. In the example below, total: <=168
allows for any total that is less than or equal to 168.
Using a previous question's input as a total
In addition to using fixed values for a total, you can also use dynamic references, such as previous responses. In the example below, T3A uses the respondent's input from Q3 as the total
decorator's input.
Displaying a table as a tiled table
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 and skipping tables
If a show column total
table is based on a previous question's selections, a single selection will be "autocoded" with the total, and the table will be skipped. In the example below, selecting one color at Q8 sets the table input to '100' for that same row, while unselected colors default to '0' using if not set: 0
.
Comments
0 comments
Please sign in to leave a comment.