Z.TEST function
Returns the one-tailed p-value of a z-test: the chance of a sample mean this high if the true mean were the value you test.
Available in Excel 2010 and later, Microsoft 365, Excel for the web, Excel for Mac 2011 and later
Excel 2010 and laterWorks in Google Sheets
Syntax
Z.TEST(array, x, [sigma])| Argument | What it means | |
|---|---|---|
array | Required | The sample data. |
x | Required | The hypothesised population mean to test against. |
sigma | Optional | The known population standard deviation. If omitted, the sample standard deviation (STDEV.S) is used. |
Returns: A one-tailed (upper) p-value between 0 and 1.
How Z.TEST works
A z-test checks whether a sample's average is consistent with a claimed or target population mean when the population standard deviation is known, for example a filling machine whose spread is known from years of data. Z.TEST returns the probability of seeing a sample average at least as high as yours if the true mean really were x. A small value (below 0.05) suggests the true mean is higher than x.
Excel calculates 1 − NORM.S.DIST((AVERAGE(array) − x) / (sigma / √n), TRUE). The result is one-tailed toward higher values: if your sample mean is below x, you get a value above 0.5. For a two-tailed p-value use =2*MIN(Z.TEST(array,x,sigma), 1-Z.TEST(array,x,sigma)). If sigma is not truly known and the sample is small, a t-test (T.TEST or T.DIST functions) is more appropriate.
Examples
1Is the machine overfilling?
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Box weights (g) | |||
| 2 | 501.2 | 499.8 | 0.0081 | |
| 3 | 498.7 | 502.9 | ||
| 4 | 502.5 | 501.6 | ||
| 5 | 503.1 | 500.4 |
Result: 0.0081
The sample average is 501.2750 g against a target of 500 g, with a known machine standard deviation of 1.5 g. p = 0.008105 (shown to 4 decimals), far below 0.05: the machine is very likely overfilling and should be recalibrated.
2Two-tailed version
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Box weights (g) | |||
| 2 | 501.2 | 499.8 | 0.0162 | |
| 3 | 498.7 | 502.9 | ||
| 4 | 502.5 | 501.6 | ||
| 5 | 503.1 | 500.4 |
Result: 0.0162
If any deviation from 500 g (over or under) matters, double the smaller tail: 0.016210 (shown to 4 decimals).
3Without a known sigma
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Box weights (g) | |||
| 2 | 501.2 | 499.8 | 0.0106 | |
| 3 | 498.7 | 502.9 | ||
| 4 | 502.5 | 501.6 | ||
| 5 | 503.1 | 500.4 |
Result: 0.0106
Leaving sigma out makes Excel use the sample standard deviation (1.5655); p = 0.010622 (shown to 4 decimals). With only 8 values a t-test would be more appropriate here.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#N/A | array is empty. | Provide sample data. |
#DIV/0! | sigma is 0, or sigma is omitted and the array has a single value. | Supply a positive sigma or more data. |
Tips
- Remember the direction: Z.TEST tests whether the mean is higher than x.
- ZTEST is the older name with identical arguments.
Google Sheets
Z.TEST also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
Z.TEST in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Finnish | Z.TESTI |
| German | G.TEST |
| Hungarian | Z.PRÓB |
| Italian | TESTZ |
| Portuguese (Brazil) | TESTE.Z |
| Portuguese (Portugal) | TESTE.Z |
| Russian | Z.ТЕСТ |
| Spanish | PRUEBA.Z.N |