ZTEST function
Returns the one-tailed p-value of a z-test: the chance of a sample mean this high if the population mean were x. Replaced by Z.TEST.
Available in All versions of Excel, including Microsoft 365 and Excel for the web (kept for compatibility)
In every Excel versionWorks in Google Sheets
Syntax
ZTEST(array, x, [sigma])| Argument | What it means | |
|---|---|---|
array | Required | The sample data. |
x | Required | The population mean you are testing against. |
sigma | Optional | The known population standard deviation. If omitted, the sample standard deviation is used. |
Returns: A one-tailed (upper tail) probability.
How ZTEST works
ZTEST checks whether a sample's average is higher than a claimed population average. It computes z = (sample mean − x) / (σ / √n) and returns 1 - NORMSDIST(z), the probability of seeing a sample mean at least this large if the true mean were x. A small result suggests the population mean is really above x.
It is one-tailed towards the high side. If the sample mean is below x you get a value above 0.5. For a two-sided test use 2 * MIN(ZTEST(array, x, sigma), 1 - ZTEST(array, x, sigma)). If you leave out sigma Excel uses the sample standard deviation, which strictly makes it a t-test situation — for small samples TTEST is more appropriate.
Compatibility note: ZTEST is one of the older statistical functions that Excel 2010 moved to the Compatibility group. It still works in every version, but for new workbooks Microsoft recommends Z.TEST. Identical arguments; rename to Z.TEST(array, x, [sigma]).
Examples
1One-tailed p-value
| A | B | C | |
|---|---|---|---|
| 1 | Data | ||
| 2 | 3 | 0.090574 | |
| 3 | 6 | ||
| 4 | 7 | ||
| 5 | 8 | ||
| 6 | 6 | ||
| 7 | 5 | ||
| 8 | 4 | ||
| 9 | 2 | ||
| 10 | 1 | ||
| 11 | 9 |
Result: 0.090574
The sample mean is 5.1. Using the sample standard deviation, the chance of a mean that high if the true mean were 4 is 0.090574 (formatted to 6 decimals) — not quite significant at 5%.
2Are bags overfilled?
| A | B | C | |
|---|---|---|---|
| 1 | Fill (g) | ||
| 2 | 503 | 0.0226 | |
| 3 | 501 | ||
| 4 | 499 | ||
| 5 | 504 | ||
| 6 | 502 | ||
| 7 | 500 | ||
| 8 | 505 | ||
| 9 | 503 |
Result: 0.0226
The machine's known standard deviation is 3 g. The sample mean of 502.125 g gives a one-tailed p-value of 0.0226 (formatted to 4 decimals). That is below 0.05, so at the 5% level the machine is filling above the 500 g target.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#N/A | The array is empty. | Check the data range. |
#DIV/0! | sigma is omitted and the sample has only one value (or no variation). | Provide sigma or more data. |
Tips
- ZTEST is one-tailed (upper). It is not the two-tailed p-value many textbooks report.
Questions
Should I still use ZTEST?
Only if the workbook must open in Excel 2007 or earlier. Otherwise use Z.TEST, which gives the same result and makes the intent clearer to the next person who reads the formula.
Will ZTEST stop working?
There is no announced removal date. Microsoft keeps compatibility functions so old workbooks keep calculating, but they get no new features.
Google Sheets
ZTEST also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
ZTEST 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 |
|---|---|
| Dutch | Z.TOETS |
| Finnish | ZTESTI |
| French | TEST.Z |
| German | GTEST |
| Hungarian | Z.PRÓBA |
| Italian | TEST.Z |
| Polish | TEST.Z |
| Portuguese (Brazil) | TESTEZ |
| Portuguese (Portugal) | TESTEZ |
| Russian | ZТЕСТ |
| Spanish | PRUEBA.Z |