LAMBDA · Statistical
Z-score LAMBDA
xl.z.score measures a value in sample standard deviations from the mean. January's $143.60 utility bill is about 1.2855 standard deviations above the four-bill average.
Syntax =xl.z.score(x, values)
=LAMBDA(x, values,
LET(
center, AVERAGE(values),
spread, STDEV.S(values),
IF(spread=0, NA(), (x - center) / spread)
)
)Arguments
| Name | Required | What to pass |
|---|---|---|
| x | Required | The value to score. It can be one of the sample values or a new one. |
| values | Required | The sample. STDEV.S divides by n − 1, so the sample needs at least two numbers. |
Examples
January against the four utility bills
=xl.z.score(143.60, B2:B5)Result 1.2855
| A | B | |
|---|---|---|
| 1 | Month | Bill |
| 2 | Jan | 143.60 |
| 3 | Feb | 96.20 |
| 4 | Mar | 118.45 |
| 5 | Apr | 88.10 |
| 6 | Z of January | 1.2855 |
xl.z.score says how unusual a bill is relative to its own sample. The four utility bills average $111.5875 and their sample standard deviation is about 24.9020. January’s $143.60 is (143.60 − 111.5875) / 24.9020, about 1.2855. It sits a bit more than one standard deviation above the mean. NORM.DIST of $143.60, with mean $111.5875 and standard deviation 24.9020205, returns the cumulative value 0.9006979. NORM.INV goes the other way. It returns the value at a probability on a normal curve with a mean and a standard deviation you supply.
The divisor is STDEV.S, the sample form, because these four months are being treated as a sample. STDEV.P would be smaller and the z-score would be larger.
Add it to the workbook
Copy the formula in the block above, including the line breaks. Choose Formulas, Name Manager, New. Set the name to xl.z.score, the scope to Workbook, and paste into Refers to. Excel Labs can do the same step: open the Advanced Formula Environment, add that name, and save it back to the workbook. A cell then calls =xl.z.score(...).
The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA even when it already has XLOOKUP, FILTER, or LET.
How it works
AVERAGE and STDEV.S are computed on the sample. The score is the value minus the mean, divided by that spread. A zero spread returns #N/A instead of a division by zero.
Limits
The value is included in the mean and the spread when you pass a sample that already contains it. That is the usual z-score of a point inside the sample. Leave it out of values if you want the score against the other points only. Text in the sample is ignored by AVERAGE and STDEV.S.