median

median, function

def nosort process median(value: _typ): _typ

Returns the median of value within each group.

Examples

table T = with
  [| as Group, as Value |]
  [| "A", 1 |]
  [| "A", 2 |]
  [| "A", 9 |]
  [| "B", 4 |]
  [| "B", 5 |]

table G[g] = by T.Group
G.Median = median(T.Value)

show table "Median" with
  g as "Group"
  G.Median as "Median"

This produces the following table:

Group Median
A 2
B 4.5

Remarks

Empty groups return the default value for the data type.

User Contributed Notes
0 notes + add a note