The MEDIANX function returns the median of the values taken by an expression that is evaluated for all the rows in a table.
MEDIANX(
table,
expression
)
- table: Table containing the rows for which the expression is evaluated.
- expression: Expression to evaluate for each row of the table.
The MEDIANX function returns a real number.
To calculate the median of the values of a column it is preferable to use the MEDIAN function.
Suppose we have in the Sales table the SalesAmount and TotalProductCoste fields containing the sales price and the total manufacturing cost. If we want to calculate the median profit, we can define the following measure:
Profit median = MEDIANX(Sales, Sales[SalesAmount] - Sales[TotalProductCost])
If we take this measure to a table disaggregated by product category, we obtain the following result: