OpenBI Docs Buy

MEDIANX

The median of an expression over a table's rows; blanks count, sorting as zero, and give BLANK when the median falls on one.

Group: Aggregation. Compatible with DAX.

Syntax

MEDIANX ( <table>, <expression> )
ParameterTypeDescription
tableTableThe rows to go through.
expressionExpression
evaluated for each row
The number worked out for each row.

Returns

Number. The middle value of the expression's results.

Remarks

  • With an even number of rows, it is the mean of the two results in the middle.
  • Unlike MEDIAN on a column, a blank result here takes part: it sorts as zero. When the middle falls on a blank, the answer is BLANK.
  • Filter the blanks out first (FILTER ( table, NOT ISBLANK ( ... ) )) when they should not count.

Examples

An even number of values

EVALUATE
ROW ( "Median", MEDIANX ( DATATABLE ( "Value", INTEGER, { { 1 }, { 2 }, { 3 }, { 10 } } ), [Value] ) )
Median
2.5

Blanks take part

5, blank, 10 and 7 sort as blank (zero), 5, 7, 10: the middle two are 5 and 7. In the second table the blank is the middle value itself.

EVALUATE
ROW (
    "Blank at an end",
        MEDIANX ( DATATABLE ( "Value", INTEGER, { { 5 }, { BLANK () }, { 10 }, { 7 } } ), [Value] ),
    "Blank in the middle",
        MEDIANX ( DATATABLE ( "Value", INTEGER, { { -5 }, { BLANK () }, { 10 } } ), [Value] )
)
Blank at an endBlank in the middle
6(blank)

MEDIAN, AVERAGEX, PERCENTILEX.INC.

Last updated · OpenBI Studio 0.3.74