Page tree
Skip to end of metadata
Go to start of metadata

The MEDIAN function is especially useful in cases where a small set of outliers could drastically skew the average if calculated as a mean.
MEDIAN can be used to aggregate facts in the same way as SUM, MAX, MIN, or AVG, but it also accepts metrics or entire metric expressions as arguments.

Description
Returns the middle value of a set of data, such that half of the values are smaller and half of the values are larger. For sets with an even number of values, the median is calculated by finding the mean of the middle two values.

Syntax
SELECT MEDIAN(…)
MEDIAN(fact)
MEDIAN(metric)
MEDIAN(metric_expression)

Examples
SELECT MEDIAN(Cost) BY ALL OTHER
SELECT MEDIAN(Date (Closed) - Date (Opened)) BY Ticket_ID
SELECT MEDIAN(Payment) BY Customer FOR PREVIOUS(Month)

  • No labels