Built-in Functions → median

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

Signature

median(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 median of the values in the column. If groupBy is used, median returns the median for each group.

Examples

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