addcoltotals

addcoltotals [options(...)]?, [column: storable]*

Appends one summary row with a total of each numeric or duration column.

addcoltotals compiles only when the enable_opal_totals feature flag is on for the customer. The same flag gates addtotals.

With no column arguments, every int64, float64, numeric, and duration column is summed. Timestamp, string, bool, and object columns are left out, including valid-from and valid-to. Pass column names or quoted patterns ("count*", "*bytes*") to choose the columns. A timestamp column cannot be totaled. Nulls are skipped, matching SQL sum. If no int64, float64, numeric, or duration column is present, the summary row is still appended.

addtotals with options(col: true) uses this summary row and also adds a Total column. That column does not include duration values. The Total value on the summary row is the column total of Total, not a row total of the summary row.

The input may be a Table, Event, Interval, or Resource. The output is a Table: time columns remain, with a null time on the summary row, and primary keys are cleared. A time-series chart no longer applies, and a later timechart rejects the result. statsby, sort, filter, and make_col still accept it.

options(labelfield: column, label: "Total") writes the label on the summary row when that column is a string, an existing variant, or a name that does not exist yet. A missing column is created as a string: null on the data rows and the label on the summary row. An existing variant stays variant. Any other existing type is left unchanged, so the summary cell keeps its sum or stays null. The default label is Total. label without labelfield has no effect.

The summary row is sorted last using a hidden column. A later sort or pick_col keeps it last. A later limit, or the row limit applied when results are displayed, can drop it when there are more data rows than the limit. The totals cover every row that reaches the verb.

Options

OptionTypeMeaning
labelfieldstringColumn that receives the summary label on the summary row.
labelstringText written into labelfield on the summary row. Defaults to Total.

Categories

Accelerable

addcoltotals is never accelerable. A dataset that only uses accelerable verbs can be accelerated, making
queries on the dataset respond faster.

Examples

addcoltotals options(labelfield: "title", label: "Grand Total"), "price"

Appends a summary row that totals the price column and labels it in the title column.


Did this page help you?