Introduction
This article describes how to go from a standard table...
...to a table with an additional column that computes the difference between specified columns:
Method
1. Select your table.
2. In the toolbar go to Automate > Browse Online Library > Table Computations > Difference Between a Pair of Columns.
3. OPTIONAL: Select the Statistic to use (if different from the default).
4. By default, it is set to choosing selections by Label but this can be changed to Column Position. The latter option allows you to choose specific columns based on the first column (for benchmarking) and the position from the end (for dynamic referencing). This ensures, for example, the last 2 columns are always used, even when a further column is added to the end.
5. Select the column under Column 1 to compute the difference from.
6. Select the column under Column 2 to compare against.
7. OPTIONAL: Untick Label new column automatically and enter new label.
8. OPTIONAL: Tick Replace table with difference to only show this new column.
9. Choose whether to show blank cells as blank or NaN.
10. Press OK.
This rule calculates then the difference between these two columns and displays it to the right of the second column. Note, this rule can only apply to a single statistic and no significance tests are conducted on these cells. It is also not compatible with tables that have column spans.
Note, if you select Switch rows and columns on your table, the rule will no longer work due to the table dimensions changing. In this case, you will have to apply the Difference Between a Pair of Rows rule instead.
Technical details
No significance tests are conducted on the computed difference.
How to apply this rule
For the first time in a project
- Select the table(s)/chart(s) that you wish to apply the rule to.
- Start typing the name of the Rule into the Search features and data box in the top right of the Q window.
- Click on the Rule when it appears in the QScripts and Rules section of the search results.
OR
- Select Automate > Browse Online Library.
- Choose this rule from the list.
Additional applications of the rule
- Select a table or chart that has the rule and any table(s)/chart(s) that you wish to apply the rule to.
- Click on the Rules tab (bottom-left of the table/chart).
- Select the rule that you wish to apply.
- Click on the Apply drop-down and choose your desired option.
- Check New items to have it automatically applied to new items that you create. Use Edit > Project Options > Save as Template to create a new project template that automatically uses this rule.
Removing the rule
- Select the table(s)/chart(s) that you wish to remove the rule from.
- Press the Rules tab (bottom-right corner).
- Press Apply next to the rule you wish to remove and choose the appropriate option.
How to modify the rule
- Click on the Rules tab (bottom-left of the table/chart).
- Select the rule that you wish to modify.
- Click Edit Rule and make the desired changes. Alternatively, you can use the JavaScript below to make your own rule (see Customizing Rules).
JavaScript
▶ Show Code
See also
- User Input for Rules for technical information on Rules.
- Rule Online Library for other examples of Rules.
- Table JavaScript and Plot JavaScript for the JavaScript that is used to write custom rules.
- JavaScript for information about the JavaScript programming language.
Next
How to Calculate the Difference Between Time Stamps
How to Compute the Difference Between a Pair of Rows in a Table