Totals at the bottom of a table
Sometimes it’s helpful to add a “Totals” row at the bottom of your table.
This example features “Totals” at the bottom of columns of flight revenues by airport.
Click Results à la Mode to clone the report and add a “Totals” row to your own table. Learn more about using HTML to customize your reports.
Add totals
Once you’ve added a table to your report, you can integrate a totals row at the bottom with the following steps.
Add the stylesheet link and script tag to the top of the HTML:
<link rel="stylesheet" href="https://mode.github.io/alamode/alamode.min.css">
<script src="https://mode.github.io/alamode/alamode.min.js"></script>
Add the customizable snippet at the bottom of the HTML:
<script>
alamode.addTotalsRow(
{
query_name: "Revenues by Airport",
table_id: "table_8bbae0ecf25c",
columns_with_totals: "all"
})
</script>
You can customize the table by editing the parameters in the snippet:
table_id
: The ID of the Mode table you want to add links to. You’ll find this ID in the pre-populated HTML code in a line that looks like this:<mode-table id="table_8bbae0ecf25c" dataset="dataset" options="table_options"></mode-table>
.query_name
: The name of the query that returns the table’s dataset. If you update the name of the query, you’ll need to update it here as well.columns_with_totals
: An array of the column(s) you want to show totals for. If you want to show totals for all numeric columns, use"all"
.
Looks like you've got a thing for cutting-edge data news.
So do we. Stay in the know with our regular selection of the best analytics and data science pieces, plus occasional news from Mode. Sign up here and we'll keep you posted: