Built-in Functions → average

average() is an aggregation function that returns the average of the values in a column.

Signature

average(double expr, [groupBy(...)])
  • expr : expression evaluating to double
  • groupBy : optional grouping function that specifies which group of data to operate over
Note

If you use the groupBy function, you must include all the leading grouping dimensions in the Insight from the top-down to the level-based measure you want to evaluate. For more information, refer to Aggregation with a Level Based Measure.

Returns

double representing the average of the values in the column. If groupBy is used, average returns the average for each group.

Examples

  • Compute the average of the values in the data column AMOUNT_SOLD.
average(Sales_Acme.Sales.AMOUNT_SOLD)
  • Compute the average of AMOUNT_SOLD by QUARTER_NUMBER.
average(Sales_Acme.Sales.AMOUNT_SOLD,
groupBy(Sales_Acme.Sales.QUARTER_NUMBER))