Explanation
The coefficient of variation measures the relative variability of data with respect to the mean. It represents a ratio of the standard deviation to the mean and can be a useful way to compare data series when means are different. It is sometimes called relative standard deviation (RSD).
In this contrived example, the standard deviation is calculated in column H with the STDEV.P function:
=STDEV.P(B5:F5)
Notice that the standard deviation is the same for all data series (1.414214) even though the means vary substantially. To calculate the coefficient of variation (CV), the formula in I5 is:
=H5/AVERAGE(B5:F5)
This formula divides the standard deviation in H5 by the mean of B5:F5, calculated with the AVERAGE function. The result is a decimal value, formatted with the percentage number format. The calculated CV values show variability with respect to the mean more clearly. In the first data series, the CV is nearly 50%. In the last data series, the CV is only .12%.
Explanation
The MEDIAN function has no built-in way to apply criteria. Given a range, it will return the MEDIAN (middle) number in that range.
To apply criteria, we use the IF function inside MEDIAN to “filter” values. In this example, the IF function filters by group like this:
IF(group=E5,data)
This expression compares each value in the named range “group” against the value in E5 (“A”). Because the criteria is applied to an array with multiple values, the result is an array of TRUE FALSE values like this:
{TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE}
In this array each TRUE corresponds to a value in group A. The IF function evaluates these results and returns the corresponding value from the named range “data”. The final result from IF is
{1;2;3;3;5;FALSE;FALSE;FALSE;FALSE;FALSE}
Notice only values in group A have survived, and group B values are now FALSE. This array is returned to the MEDIAN function, which automatically ignores FALSE values and returns median value, 3.
Note: when IF is used this way to filter values with an array operation, the formula must be entered with control + shift + enter.
Additional criteria
To apply more than one criteria, you can nest another IF inside the first IF:
{=MEDIAN(IF(criteria1,IF(criteria2,data)))}
To avoid extra nesting, you can also use boolean logic in the criteria .