Introduction
This article describes how to go from a standard table...
...to a table that appends a custom note to the table footer....
...and additionally matches a cell marker to signify low sample size...
...or points of interest:
Requirements
- A table with columns.
- You have read How to Create a Custom Rule.
Method - Add text to footer
1. Select your table.
2. Go to Automate > Custom Rule in the toolbar.
3. Paste the below into the dialog:
form.setHeading("Add custom footnote");
form.setSummary("Add custom footnote");
var footers = table.extraFooters;
footers.push("Warning: Some cells are less than 100");
table.extraFooters = footers;
- In this code, we first pull the existing footer text and declare it as
footers
. - We then use the
push
function to append our text to this variable. - Finally, we set our table footer with the updated
footers
variable.
4. Press the blue Play button > Close > OK.
Method - Less than a specified threshold
1. Select your table.
2. Go to Automate > Custom Rule in the toolbar.
3. Paste the below into the dialog:
form.setHeading("Add custom footnote");
form.setSummary("Add custom footnote");
var target = 100;
table.addFootNoteForCellsLessThan('Column Sample Size', target, '*', '* sample size <' + target);
- In this code, we first set the target.
- We then use the
addFootNoteForCellsLessThan
function to pass the following arguments: statistic, limit, footnote marker, and footnote text. - The text from the last argument will be added to the footer text and the marker will be added to all cells where the specified statistic is less than 100.
4. OPTIONAL: Change the target value if necessary.
5. Press the blue Play button > Close > OK.
Method - Identify columns of interest
1. Repeat the first 3 steps from above.
2. Paste the below into the dialog:
form.setHeading("Add custom footnote");
form.setSummary("Add custom footnote");
var target_column_labels = ['25 to 34','35 to 49'];
for (var i = 0; i < target_column_labels.length; i++) {
var column = table.columnIndex(target_column_labels[i]);
// Confirm that the column index was found. If not found, the index will be -1.
if (column != -1) {
// Yes, it was found. Now go through each row in the column,
// adding the footnote marker.
for (var row = 0; row < table.numberRows; row++)
table.addFootNote(row, column, '*', null, '* This is our target market');
}
}
- In this code, we first set the target column labels to apply the condition to. These must match those in the table.
- Next, we loop through each column until we find the specified column labels.
- We then loop through the rows and use the
addFootNote
function to pass the following arguments: row index, column index, footnote marker, index of statistic to display marker next to, and footnote text. - The text from the last argument will be added to the footer text and the marker will be added to all cells within the specified columns.
3. OPTIONAL: Change target_column_labels to refer to the appropriate column labels in your table.
4. OPTIONAL: Change the marker argument in addFootNote
to specify a different character.
5. OPTIONAL: Change the index of statistic to display marker next to argument in addFootNote
by using the zero-based index. Here, we will set this to null in order to place the marker alongside the first statistic.
6. OPTIONAL: Change the footnote text argument in addFootNote
.
7. Press the blue Play button > Close > OK.
Next
See Also
How to Add a Footnote for Cells with Small Sample Sizes
How to Add a Column Header Footnote Indicating Small Sample Sizes