How to Use ZTEST in Excel

ZTEST is Excel's implementation of the one-sample z-test, a statistical hypothesis test that determines whether a sample mean differs significantly from a known or hypothesized population mean....

Key Insights

  • ZTEST returns a one-tailed p-value for hypothesis testing when you know the population standard deviation, making it ideal for quality control scenarios where historical variance is established
  • The function requires at least 30 data points to be statistically valid, and you should use T.TEST instead when population standard deviation is unknown or sample size is small
  • A ZTEST result of 0.025 means there’s a 2.5% probability your sample came from the hypothesized population—multiply by 2 for two-tailed tests to get the full significance picture

What is ZTEST and When to Use It

ZTEST is Excel’s implementation of the one-sample z-test, a statistical hypothesis test that determines whether a sample mean differs significantly from a known or hypothesized population mean. Unlike its cousin T.TEST, ZTEST assumes you know the population standard deviation—a critical distinction that dictates when you should use each function.

Use ZTEST when you’re comparing sample data against a known benchmark and you have historical data about population variance. Common scenarios include:

Quality Control: A manufacturing plant produces bolts with a target weight of 50 grams. Historical data shows a population standard deviation of 2.5 grams. You sample 40 bolts from today’s production run to verify the process remains on target.

A/B Testing with Historical Baselines: Your website historically converts at 3.2% with a known standard deviation. You implement a new design and want to test if the conversion rate has genuinely changed based on a week’s worth of data.

Survey Analysis: You’re comparing regional survey responses against national averages where the national standard deviation is published and reliable.

The key requirement: you need to know (or have a very reliable estimate of) the population standard deviation before the test. If you’re estimating sigma from your sample data, T.TEST is the appropriate choice.

ZTEST Syntax and Parameters

The ZTEST function follows this structure:

=ZTEST(array, x, [sigma])

array: Your sample data range. This should contain numerical values representing your observations. Excel requires this to be a contiguous range or array.

x: The hypothesized population mean you’re testing against. This is your null hypothesis value—the benchmark you believe your population follows.

sigma (optional): The known population standard deviation. If omitted, Excel calculates the standard deviation from your sample data. However, this defeats the purpose of using ZTEST over T.TEST, so you should almost always provide this parameter.

Excel offers two versions of this function: ZTEST (legacy, available in all versions) and Z.TEST (introduced in Excel 2010). They’re functionally identical, but Microsoft recommends using Z.TEST for better compatibility. Both return a one-tailed p-value.

Here’s a basic example:

Sample data in A1:A10: 52, 48, 51, 49, 53, 50, 52, 48, 51, 50
Hypothesized mean: 50
Known population std dev: 2.5

=ZTEST(A1:A10, 50, 2.5)

This returns the probability that your sample came from a population with mean = 50 and standard deviation = 2.5.

Step-by-Step Implementation

Let’s work through a complete quality control example. A pharmaceutical company produces tablets that must contain 500mg of active ingredient. Historical manufacturing data shows a population standard deviation of 15mg. Today’s quality inspector samples 35 tablets to verify the process is on target.

Step 1: Enter your sample data

Column A (Tablet Weights in mg):
A1: 505
A2: 492
A3: 510
A4: 498
A5: 502
... (continue through A35)
A35: 495

Step 2: Apply the ZTEST function

Cell C1: =ZTEST(A1:A35, 500, 15)

Step 3: Interpret the result

If ZTEST returns 0.0485, this is your one-tailed p-value. It means there’s a 4.85% probability of observing your sample mean (or something more extreme) if the true population mean is 500mg.

For a two-tailed test (testing if the mean is different rather than specifically higher or lower), calculate:

Cell C2: =2*MIN(ZTEST(A1:A35, 500, 15), 1-ZTEST(A1:A35, 500, 15))

This gives you the two-tailed p-value. At a 95% confidence level (α = 0.05), if this value is less than 0.05, you reject the null hypothesis—your production process has shifted from the 500mg target.

Step 4: Calculate the actual sample mean for context

Cell C3: =AVERAGE(A1:A35)

This helps you understand the direction and magnitude of any deviation.

Practical Examples and Use Cases

Example 1: Marketing Campaign Performance

Your e-commerce site has a historical conversion rate of 3.5% with a standard deviation of 0.8%. After implementing a new checkout flow, you track 50 days of conversion rates.

Daily conversion rates in B1:B50

Hypothesized mean: 3.5
Known std dev: 0.8

=ZTEST(B1:B50, 3.5, 0.8)

If the result is 0.018, you have strong evidence (p < 0.05 for a one-tailed test) that conversion rates have changed. Check the actual mean with =AVERAGE(B1:B50) to determine if it’s an improvement or decline.

Example 2: Student Test Scores vs National Average

The national average SAT math score is 528 with a standard deviation of 120 points. Your tutoring program wants to verify if students score differently than the national average.

Student scores in D1:D45

=2*MIN(ZTEST(D1:D45, 528, 120), 1-ZTEST(D1:D45, 528, 120))

Using the two-tailed formula, a result below 0.05 indicates your students perform significantly differently than the national average.

Example 3: Determining Significance at Different Confidence Levels

Sample data: E1:E60
Hypothesized mean: 100
Population std dev: 12

One-tailed p-value: =ZTEST(E1:E60, 100, 12)
Two-tailed p-value: =2*MIN(ZTEST(E1:E60, 100, 12), 1-ZTEST(E1:E60, 100, 12))

Significant at 90% confidence? =IF(ZTEST(E1:E60, 100, 12)<0.10, "YES", "NO")
Significant at 95% confidence? =IF(ZTEST(E1:E60, 100, 12)<0.05, "YES", "NO")
Significant at 99% confidence? =IF(ZTEST(E1:E60, 100, 12)<0.01, "YES", "NO")

Common Pitfalls and Best Practices

Pitfall 1: Using Sample Standard Deviation Instead of Population

Incorrect:

=ZTEST(A1:A30, 50, STDEV.S(A1:A30))

This defeats the purpose of ZTEST. If you’re calculating standard deviation from your sample, use T.TEST instead:

Correct:

=T.TEST(A1:A30, {50}, 2, 1)  // For one-tailed

Or stick with ZTEST only when you have a known population standard deviation from historical data:

=ZTEST(A1:A30, 50, 2.5)  // 2.5 from historical records

Pitfall 2: Insufficient Sample Size

ZTEST relies on the Central Limit Theorem, which requires adequate sample size. The rule of thumb: minimum 30 observations. With smaller samples, T.TEST is more appropriate.

Check your sample size:

=IF(COUNT(A1:A100)<30, "Use T.TEST instead", "ZTEST is appropriate")

Pitfall 3: Misinterpreting One-Tailed vs Two-Tailed Results

ZTEST returns a one-tailed p-value. If you’re testing whether the mean is different (not specifically higher or lower), you need the two-tailed conversion:

One-tailed (testing if mean is greater than hypothesized):

=ZTEST(A1:A40, 100, 15)

Two-tailed (testing if mean is different):

=2*MIN(ZTEST(A1:A40, 100, 15), 1-ZTEST(A1:A40, 100, 15))

Best Practice: Create a Reusable Template

Build a testing template that handles both scenarios:

Sample Data: A1:A100
Hypothesized Mean: C1
Population Std Dev: C2
Alpha Level: C3 (e.g., 0.05)

Sample Size: =COUNT(A1:A100)
Sample Mean: =AVERAGE(A1:A100)
One-Tailed P-Value: =ZTEST(A1:A100, C1, C2)
Two-Tailed P-Value: =2*MIN(ZTEST(A1:A100, C1, C2), 1-ZTEST(A1:A100, C1, C2))
Reject Null (One-Tailed)?: =IF(ZTEST(A1:A100, C1, C2)<C3, "Reject", "Fail to Reject")
Reject Null (Two-Tailed)?: =IF(2*MIN(ZTEST(A1:A100, C1, C2), 1-ZTEST(A1:A100, C1, C2))<C3, "Reject", "Fail to Reject")

This template gives you complete visibility into your hypothesis test results and makes it easy to adjust parameters and interpret outcomes correctly. Remember: ZTEST is powerful when you have known population parameters, but don’t force it when T.TEST is the statistically appropriate choice.

Liked this? There's more.

Every week: one practical technique, explained simply, with code you can use immediately.