Where the Statistic being shown on a table or a chart is naturally a percentage, you can press the to display or hide the percentage sign.
In some situations, such as when computing Net Promoter Score the results of a calculate may be interpretable as percentages, but this button will not be available, as the statistic in which the outputs are stored, typically the Average, are not percentages.
A workaround is to:
- Place a statistic on the table that contains % in its name. The example below assumes that this statistic is % Share; if you use a different statistic, make sure that you modify the code below.
- Insert some Custom Rule to transfer the results from one statistic to another statistic that contains percentages. An example, which inserts the Average data into % Share is shown below. This code also renames the statistic as Net Promoter Score but you can change this as well.
- Remove the original statistic from the table.
- If necessary, press .
//Hijack the % Share statistic to show the Average with %
//CHANGE if you want to show the "real" % Column Share in the table
//change that to a different % statistic you're not using
var pctstat="% Share";
//CHANGE the text in "" below to the name you want for your statistic
var newname="Net Promoter Score";
//create variables for number of rows/columns for loop
var n_rows = table.numberRows; var n_columns = table.numberColumns;
//get the Average values shown in the table var averages = table.get("Average");
//get the current percentage values to overwrite
var percents = table.get(pctstat);
//loop through the cells in each row/column for (var r = 0; r < n_rows; r++) for (var c = 0; c < n_columns; c++)
//overwrite the percent value with the average value percents[r][c] = averages[r][c];
//write the new values to the table table.set(pctstat, percents);
//rename the percent statistic with what you want the new one called form.setTranslation(pctstat,newname);
How to Customize Fonts in a CreateCustomTable R Table
How to Customize Labels Used for Quarters in a Date Variable
Article is closed for comments.