aggregators

Aggregations combine multiple values into one result per group. Aggregators are Envision processes with grouping and ordering options. See also: Selectors.

Aggregators catalog

Basic: argmax argmin argwhichever areSame count distinct distinctapprox max min product single sum

Logic: all any same whichever

Ordered: changed concat first join last smudge

Statistics: avg entropy median mode percentile stdev stdevp

Ranvar: mixture ranvar ranvar.buckets sum

Zedfunc: sum

Aggregation arguments and tables

Regular arguments define the source table. Group arguments (after a ;) are aligned to the group table.

table Orders = with
  [| as Product, as Qty |]
  [| "apple", 3 |]
  [| "apple", 7 |]
  [| "orange", 2 |]

table Products[product] = by Orders.Product

Products.P90 = percentile(Orders.Qty; 0.9)
Products.Sold = sum(Orders.Qty)

show table "Products" with
  product
  Products.Sold
  Products.P90

In assignments, when by and default are omitted, the group table defaults to the table on the left side of the assignment (the left table rule). Aggregations are allowed when the group table can be broadcast to the source table.

Explicit by and at options control the grouping and the output table. When the explicit by/at pair duplicates the implicit relationship, the options are rejected to favor the concise natural join syntax. See by and at.

Aggregations are valid in assignments, filters, and tile inputs. Tile-level grouping is controlled by group by and group into, and order by applies after the aggregation. See group and order.

Scalar aggregation (by 1)

The special form by 1 is equivalent to into Scalar. Other constants are not accepted.

table Orders = with
  [| as Qty |]
  [| 3 |]
  [| 7 |]

Orders.Total = sum(Orders.Qty) by 1

show table "Orders" with
  Orders.Qty
  Orders.Total

Default group tables

In tiles, the default group table depends on the tile type: scalar, summary, and form aggregate into Scalar, while linechart aggregates into Day. The tile-level group by and group into options override those defaults.

In filters, aggregations inside where default to Items, while aggregations inside when default to Day. These defaults can be overridden with by, into, or by/at options.

Range and ordered aggregations

The sort, scan, over, and when options apply to aggregator calls. See sort, scan, over, and when.

User Contributed Notes
0 notes + add a note