Aggregate with Grand Totals
For users who want to see aggregated column values in a table, such as the total sum of values in a column, or an average value of a particular column, Deephaven offers two options: using the Show Totals option in the right-click context menu, and by configuring custom totals via the query language.
Show Totals in the UI
You can add a Grand Totals section to any open table in the Deephaven console. Right-click any column header and select Show Totals.
The Grand Totals section seen below displays the sum total of values of these columsn in the StockTrades table. Sum is the default operation, but you can configure your own totals via the Deephaven Query Language that sets one or more aggregations on specified columns. This is discussed below.
You can re-hide or move the Grand Totals to the top or bottom of the table from the right-click table data menu:
How to Add Totals Programmatically
If you'd like to see aggregated column values for your data, you can add a Totals section at the top or bottom of your table via a query.
from deephaven import TotalsTableBuilder
t1 = db.t("LearnDeephaven", "StockQuotes").where("Date=`2017-08-25`")
totalsTable = t1.setTotalsTable(TotalsTableBuilder()/
.setOperation("Bid", "Avg")/ # this sets the first aggregation to average Bid values
.setOperation("Ask", "Avg")) # this sets the second aggregation to average Ask values
Once your table opens in the Console, right-click any column header of "totalsTable" and select Show Totals.
Now, a Grand Totals bar will appear above the column headers, which can be expanded and collapsed using the button at the right of the table. Here, we see that the first two entries are the averages of Bid and Ask, respectively, as specified in the query, while total sums are shown for the rest of the table's columns.
To learn more, see the full documentation on Tables Totals.