Why a fair experiment starts with four averages
Every week someone in a business says "let's try it and see". A new shelf layout, a different email subject line, a cheaper supplier, a new menu board. Then the numbers come in, one version looks a little better, and the meeting decides on the strength of a gap that may be nothing more than luck. The tool that separates a real difference from ordinary noise is the analysis of variance, ANOVA for short, and it begins with something every Excel user already knows: averages.
This free first lesson of ANOVA & Experimental Design in Excel is for analysts, operations and marketing people, students in a statistics or research-methods course, and anyone who has to judge a test with more than two versions. You do not need any statistics software. Everything is done with ordinary worksheet functions, so you can see every number and explain it to a manager who has never heard of an F test.
In the lab above you work with Marlowe Coffee Co., a fictional coffee chain. Marlowe wants to know whether the way pastries are displayed changes how many are sold. Twenty-four stores were randomly given one of four displays for four weeks: the Classic tray, a Tiered stand, a Lit case and a Counter-front basket. The result for each store is the average number of pastries sold per day. Before any test can be run, you need the four group means, the grand mean and the distance between them. That is exactly what this lesson builds.
The core idea: factor, levels, response and the grand mean
An experiment has a factor, the thing you deliberately change. Here the factor is the display. The versions of the factor are its levels or groups: four displays, so four levels. The number you measure on every unit is the response: pastries sold per day. Each store is one experimental unit.
Three design ideas make the comparison fair. Randomisation means a random draw, not the regional manager, decides which store gets which display, so busy city-centre stores are not all handed the shiny new case. Replication means each display is tried in several stores, here six, so that one unusual store cannot decide the result. Blocking groups similar units together and compares displays within each group; you meet it in the randomised block lab later in the course. When every group has the same number of units, as here, the design is called balanced.
The grand mean is the average of all 24 stores, regardless of display. It is the best guess for a store if the display made no difference at all. Each group mean minus the grand mean is that display's estimated effect: a positive number means the display sells more than the average store, a negative number means it sells less. ANOVA then asks one question: are these effects larger than the store-to-store variation would produce by chance if all four displays were really equal?
Worked example: the Marlowe display trial
The lab data come in long format: one row per store, with the store code in column A, the display label in column B and pastries per day in column C. This is the shape a database export or a form normally produces, and it is the shape ANOVA formulas in Excel handle most easily. Sorted by display, the 24 results look like this:
| Display | Stores (n) | Pastries per day (the six stores) | Mean | Mean − grand mean |
|---|---|---|---|---|
| Classic | 6 | S01 42, S06 51, S10 45, S15 53, S17 44, S23 47 | 47.0 | -5.0 |
| Tiered | 6 | S03 56, S05 47, S11 58, S14 52, S20 55, S21 50 | 53.0 | +1.0 |
| Lit case | 6 | S02 54, S08 60, S09 65, S16 55, S19 53, S22 61 | 58.0 | +6.0 |
| Counter-front | 6 | S04 56, S07 48, S12 46, S13 51, S18 54, S24 45 | 50.0 | -2.0 |
| All stores | 24 | total 1,248 | 52.0 (grand mean) | 0.0 |
The Lit case leads with 58 pastries a day, the Classic tray trails with 47, and the Tiered and Counter-front displays sit in between. The grand mean is 1,248 / 24 = 52.0, and because each display has six stores it equals (47 + 53 + 58 + 50) / 4 as well. The deviations, −5, +1, +6 and −2, add up to zero, which is always true when each is weighted by its group size.
The strip chart tells a more honest story than a bar chart alone. The Lit case stores are mostly above the dashed line and the Classic stores are mostly below it, but the clouds of dots overlap: the best Classic store (S15, 53) sold as many pastries as the weakest Lit case store (S19, 53) and more than three of the Tiered stores. Inside every display the best and worst store are 11 or 12 pastries a day apart. The question for the rest of the course is whether a spread of 11 between the best and worst display mean is big compared with that noise.
These are the formulas the lab expects. The ranges are locked with $ so the formula can be copied down the summary table without the data range sliding:
| Cell | What it holds | Formula | Result |
|---|---|---|---|
| B28 | Stores with the Classic display | =COUNTIF($B$2:$B$25,A28) | 6 |
| C28 | Mean pastries, Classic | =AVERAGEIF($B$2:$B$25,A28,$C$2:$C$25) | 47.0 |
| C30 | Mean pastries, Lit case (copied down) | =AVERAGEIF($B$2:$B$25,A30,$C$2:$C$25) | 58.0 |
| B33 | Grand mean of all 24 stores | =AVERAGE(C2:C25) | 52.0 |
| D28 | Deviation of Classic | =C28-$B$33 | −5.0 |
| D30 | Deviation of Lit case | =C30-$B$33 | +6.0 |
| (check) | Deviations weighted by n must add to zero | =SUMPRODUCT(B28:B31,D28:D31) | 0 |
Seen as deviations, the result becomes a set of effects that sum to zero. This is the language ANOVA uses. The model behind it says that every store's result equals the grand mean, plus the effect of its display, plus a residual that captures everything else about that store: its location, its staff, the weather on its street. Store S09, a Lit case store that sold 65 pastries, splits like this:
The display effect is the same for all six Lit case stores. The residual is different for each store and averages to zero within a group. Lesson 2 squares and adds these pieces: the squared display effects give the variation between displays, the squared residuals give the variation within displays. Everything ANOVA does later, the F ratio, the p-value, the effect sizes, comes from comparing those two totals.
How to do it in Excel, step by step
- Check the data. Click any cell in the table and press Ctrl+A to see the block Excel recognises. Make sure every row has a display label, the labels are spelled consistently (a trailing space turns "Classic " into a fifth group) and the response is a number, not text.
- Build the summary table. In A28:A31 type the four display names, or in Excel 365 enter
=UNIQUE(B2:B25)in A28 and let it spill. Add headers for stores, mean and deviation in row 27. - Count the units. In B28 enter
=COUNTIF($B$2:$B$25,A28). Press F4 while the cursor is in a range to add the dollar signs. Select B28:B31 and press Ctrl+D to fill down. Every display should show 6. - Compute the group means. In C28 enter
=AVERAGEIF($B$2:$B$25,A28,$C$2:$C$25)and fill down to C31. The first argument is where the labels are, the second is the label to match, the third is what to average. - Compute the grand mean. In B33 enter
=AVERAGE(C2:C25). Cross-check it with=AVERAGE(C28:C31), which gives the same 52.0 because the design is balanced. - Compute the deviations. In D28 enter
=C28-$B$33and fill down. Lock B33 with F4, otherwise the copied formulas point at the empty cells below it. - Chart the means. Select A27:A31, hold Ctrl and select C27:C31, then choose Insert › Charts › Clustered Column (or press Alt+F1). Use the + Chart Elements button to add an axis title such as "Pastries per day", and give the chart a title that states the question.
- Optional: a strip chart. Give each display a number 1 to 4 in a helper column with
=MATCH(B2,$A$28:$A$31,0), then insert Insert › Charts › Scatter with that number on the x-axis and pastries on the y-axis. You see every store, not just the averages.
Designing the experiment before you open Excel
Good analysis cannot rescue a poor design, so a few minutes of planning pay off. Write down the response before the trial starts and measure it the same way in every unit: here, average pastries per day over the same four weeks. Decide the levels in advance. Choose units that are as similar as possible, and if they are not, think about blocking by region or store size.
For a fair random assignment in Excel, list the 24 stores, add a column with =RAND(), copy it and paste as values so it stops changing, sort by that column and give the first six stores the Classic display, the next six the Tiered stand, and so on. In Excel 365, =SORTBY(A2:A25,RANDARRAY(24)) does the shuffle in one formula. Keep the file: being able to show how the assignment was made is part of a credible result.
Finally, keep the groups the same size if you can. A balanced design makes the arithmetic simpler, makes the test less sensitive to unequal variances, and makes the grand-mean check above work. Six stores per display is a small trial. It is enough to learn the method, and the course later shows how effect size helps you judge whether a bigger trial would be worth running.

Common mistakes and how to spot them
- Unlocked ranges. If the mean for Counter-front looks odd and the formula in C31 reads
AVERAGEIF(B5:B28,…), the ranges slid when you copied. Lock them with F4 and copy again. - Averaging the whole column.
=AVERAGE(C2:C25)in every row gives 52 four times. A summary table where all group means are identical is the signal. - Inconsistent labels. "Lit case", "Lit Case" and "Lit case " look alike. AVERAGEIF is not case-sensitive, but a trailing space makes a different label, so a group shows n = 5 and a phantom group appears. Check that the counts add up to 24.
- Deviation the wrong way round. Grand mean minus group mean flips every sign, so the best display shows a negative effect. The convention is group mean minus grand mean.
- Using the median. The median is robust, but ANOVA is built on means and squared deviations. Use AVERAGE and AVERAGEIF throughout.
- Reading a winner off the bar chart. A gap of 11 pastries looks decisive on a column chart that starts at zero and even more so on one that starts at 40. Only the comparison with within-group noise, from lesson 2 on, says whether it is real.
- Forgetting the design. If the stores chose their own display, the "effect" could simply be that keen managers picked the new case. No formula fixes that, which is why randomisation comes first.
Quick reference: Excel functions and shortcuts in this lesson
| Function or shortcut | What it does | Example in this lesson |
|---|---|---|
AVERAGEIF(range, criteria, average_range) | Mean of the values whose label matches the criteria | =AVERAGEIF($B$2:$B$25,A28,$C$2:$C$25) |
COUNTIF(range, criteria) | Counts rows with a given label | =COUNTIF($B$2:$B$25,A28) |
AVERAGE(range) | Arithmetic mean of all values | =AVERAGE(C2:C25) |
SUMPRODUCT(a, b) | Multiplies two ranges and adds the products | Check that the weighted deviations sum to 0 |
STDEV.S(range) | Sample standard deviation | Spread inside one display (with FILTER or a helper column) |
UNIQUE(range) (Excel 365) | Lists each group label once | =UNIQUE(B2:B25) |
RAND() / RANDARRAY(n) | Random numbers for a fair assignment | Sort stores by a random column before assigning displays |
| F4 | Cycles a reference through $A$1, A$1, $A1, A1 | Lock $B$2:$B$25 before copying down |
| Ctrl+D | Fills the top cell of a selection down | Copy C28 to C29:C31 |
| Alt+F1 | Inserts a default chart of the selection | Quick column chart of the means |
Real-world uses
- Retail and hospitality. Compare shelf layouts, menu boards, opening hours or staff training programmes across stores, with stores as the units.
- Digital marketing. Compare three or four email subject lines, landing pages or ad creatives on conversion rate or revenue per visitor, when an A/B test grows into an A/B/C/D test.
- Manufacturing and quality. Compare the output or defect rate of several machines, shifts, suppliers or settings of a process parameter.
- Agriculture and science. Compare fertiliser types, feeds or treatments on plots or animals, the classic setting where the method was first developed.
- HR and education. Compare test scores after different training formats, or productivity across teams that adopted different tools, keeping in mind that people are rarely randomised.
What you will build in the rest of this course
This first lesson is free. The labs that follow are part of the full course, a one-time purchase of $9.90, and they turn these four means into a complete analysis of the Marlowe trial and two further experiments.
Sums of Squares: SSB, SSW and SST with DEVSQ. You split the total variation of pastry sales into a between-display part and a within-display part with DEVSQ, and see that the two always add up to the total.
The One-Way ANOVA Table: df, Mean Squares, F and the p-Value. You complete the classic ANOVA table, degrees of freedom, mean squares and the F ratio, and decide with F.DIST.RT and F.INV.RT whether the displays really differ.
Effect Size: Eta Squared, Omega Squared and Cohen's f. You go beyond the yes/no of a p-value and measure how much of the variation the display explains with eta squared, omega squared and Cohen's f.
Checking the Assumptions: Variance Ratio, Residuals & Levene's Test. You check whether ANOVA's assumptions hold: compare the group variances, compute the residuals and run Levene's test with ordinary formulas.
Post-Hoc Tests: Tukey HSD and Bonferroni-Adjusted t-Tests. Once you know the displays differ, you find out which pairs differ with Tukey's honestly significant difference and compare it with Bonferroni-adjusted t-tests.
Two-Way ANOVA without Replication: The Randomised Block Design. You test three menu boards in a randomised block design, remove the store-to-store differences and see how blocking sharpens the test.
Factorial Experiments: Main Effects, Interaction & the Interaction Plot. You analyse a 2 × 3 price × placement experiment: cell means, main effects, the interaction F test and an interaction plot that shows when one factor changes the effect of the other.
Summary
A one-factor experiment compares several versions of one thing on a measured response. Randomise the units, replicate each level and, where possible, keep the groups the same size. In Excel, COUNTIF and AVERAGEIF on long-format data give the group sizes and means, AVERAGE gives the grand mean, and group mean minus grand mean gives each level's effect. For Marlowe, the Lit case runs six pastries a day above the grand mean of 52 and the Classic tray five below it. Whether that is a real difference depends on the store-to-store noise, and measuring that noise is where ANOVA proper begins.
Now scroll up to the lab and build it yourself: the four means with AVERAGEIF, the grand mean, the deviations and a column chart. The coach checks each step and explains what went wrong if a number does not match.
Frequently asked questions
What is the grand mean in ANOVA?
The grand mean is the average of all observations in the experiment, regardless of group. In a balanced design, where every group has the same size, it also equals the average of the group means.
How do I calculate group means in Excel?
With data in long format, use AVERAGEIF(label range, group label, value range), for example =AVERAGEIF($B$2:$B$25,A28,$C$2:$C$25), and copy it down for each group. A PivotTable with the group in Rows and the value summarised as Average gives the same result.
What is the difference between a factor and a level?
The factor is the variable you deliberately change in the experiment, such as the type of display. The levels are its versions, such as Classic, Tiered, Lit case and Counter-front.
Why do I need ANOVA instead of comparing the averages?
Group means always differ a little just by chance. ANOVA compares the differences between the means with the variation inside the groups and tells you whether the gaps are larger than noise would produce.
Why should an experiment be randomised?
Random assignment makes it unlikely that the groups differ systematically before the trial starts, for example that the busiest stores all receive the same display. Without it, an apparent effect may come from how the units were chosen.
Can Excel do a one-way ANOVA?
Yes. The Analysis ToolPak has an Anova: Single Factor tool, and you can also build the whole ANOVA table with formulas such as DEVSQ, F.DIST.RT and F.INV.RT, which is what this course does so the results update automatically.
Keep going: ANOVA & Experimental Design in Excel: One-Way, Two-Way & Post-Hoc Tests
This free lab is lesson 1 of 20. Unlock the other 19 hands-on labs, the final exam and your certificate for a one-time CHF 9.90.
- Sums of Squares: SSB, SSW and SST with DEVSQ
- The One-Way ANOVA Table: df, Mean Squares, F and the p-Value
- Effect Size: Eta Squared, Omega Squared and Cohen's f
- Checking the Assumptions: Variance Ratio, Residuals & Levene's Test
- Post-Hoc Tests: Tukey HSD and Bonferroni-Adjusted t-Tests
- Two-Way ANOVA without Replication: The Randomised Block Design
- Factorial Experiments: Main Effects, Interaction & the Interaction Plot
- Unequal Group Sizes: One-Way ANOVA When Stores Drop Out
- Welch's ANOVA: Comparing Means When the Spreads Differ
- Confidence Intervals for Group Means and Differences with the Pooled MS Within
- Planned Contrasts: Testing the Question You Actually Asked
- Scheffé's Method: Safe Comparisons Chosen After Seeing the Data
- Trend Analysis: Linear and Curved Effects of an Ordered Factor
- Simple Effects: Where Exactly Does the Bonus Work?
- Latin Square Design: Removing Store and Week Effects at Once
- ANCOVA: Adjusting Group Means for a Pre-Test Covariate
- Random Effects: Variance Components and the Intraclass Correlation
- When the Spread Grows with the Mean: Log Transform Before ANOVA
- Final Project: Experiment Readout Dashboard for the Cold-Brew Launch