Configure native totals before including the Table View. Use arrays with supported properties. Column names below are placeholders for numeric columns selected by the actual query.
$totalsFormat = 'inline';
$viewtotals = [
['name' => 'Subtotal', 'col' => 'SUBTOTAL', 'prefix' => '$'],
['name' => 'Tax', 'col' => 'TAX', 'prefix' => '$'],
['name' => 'Total', 'calc' => '%SUBTOTAL% + %TAX%', 'prefix' => '$'],
['name' => 'Rows', 'length' => true],
['name' => 'Note', 'static' => 'Current selection']
];name labels a total; col sums a numeric result column. calc refers to previously configured totals with %column% tokens. length counts displayed records, and static supplies page-owned text. prefix, suffix and style control presentation. totalsFormat defaults to inline; break places totals on separate lines.
The native col syntax also supports a simple categorical count, such as 'col' => 'STATUS=paid', for an actual selected column/value. Keep formulas and identifiers page-owned.
Ordinary totals operate on the displayed query result and use floating-point/two-decimal presentation. With pagination, they may describe only that page. For a bounded complete summary, choose a query and pagination policy that cover the intended result; retain pagination on growing histories. Do not treat formatted display totals as an exact accounting ledger or combine different currencies.
Exact decimal totals
$viewtotals = [[
'name'=>'Total service charges', 'col'=>'CHARGES',
'decimal'=>true, 'prefix'=>'CAD '
]];
decimal=true uses the shared exact-decimal sum over the final filtered query rather than the ordinary floating-point presentation path. The query must select a real numeric CHARGES column. Pagination still limits the selected result, so use an unpaginated bounded summary for a complete filtered accounting total and retain pagination on growing detailed histories. Keep currencies separate.