Skip to content

Avg

aggregating category: aggregation no `||`

Returns the mean of the given parameters or inputs, folding ARRAY inputs element-by-element.

Without parameters, Avg averages every available input. When parameters are given, it averages only those parameters/fields. An ARRAY input is folded element-by-element (the same way Min/Max/Sum/Count fold arrays), so GetCDMTableId(@idx, :key)[] => Avg() returns the mean of all matched values.

NULL values and NULL ARRAY elements are skipped — the mean is sum(present values) / count(present values), mirroring SQL AVG(expr). The result is always FLOAT. When there are no present (non-NULL) values the result is NULL (no division by zero).

Avg accepts only numeric (INT/FLOAT) values; dates and strings are rejected at setup.

Parameters

Nvalues Optional — accepts: field, FLOAT, INT

The Nth value to average. May be a field reference (scalar or ARRAY) or a static number.

Input type

  • FLOAT
  • INT
  • ARRAY

Output type

  • FLOAT

Examples

Average across all inputs

Avg()

Mean of a collected ARRAY

GetCDMTableId(@line_index, :claim_id, :amount)[] => Avg()

See also

Sum, Count, Min, Max