Statistical function

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])
ArgumentWhat it means
arrayRequiredThe sample data.
xRequiredThe hypothesised population mean to test against.
sigmaOptionalThe 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?

D2fx=Z.TEST(A2:B5, 500, 1.5)
ABCD
1Box weights (g)
2501.2499.80.0081
3498.7502.9
4502.5501.6
5503.1500.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

D2fx=2*MIN(Z.TEST(A2:B5, 500, 1.5), 1-Z.TEST(A2:B5, 500, 1.5))
ABCD
1Box weights (g)
2501.2499.80.0162
3498.7502.9
4502.5501.6
5503.1500.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

D2fx=Z.TEST(A2:B5, 500)
ABCD
1Box weights (g)
2501.2499.80.0106
3498.7502.9
4502.5501.6
5503.1500.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.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 16 KB

Common errors and how to fix them

ErrorWhy it happensFix
#N/Aarray 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.

LanguageFunction name
FinnishZ.TESTI
GermanG.TEST
HungarianZ.PRÓB
ItalianTESTZ
Portuguese (Brazil)TESTE.Z
Portuguese (Portugal)TESTE.Z
RussianZ.ТЕСТ
SpanishPRUEBA.Z.N