Calculate ANOVA Sum of Squares Between Groups and Mean Square in Excel
Question details
Calculate the between-groups sum of squares (SSB) and mean square between groups (MSB) for a one-way ANOVA.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user has multiple groups and needs to compare each group mean with the grand mean, weighted by group size.
- Observed behavior
- The required result is SSB = Σ nᵢ(meanᵢ − grand mean)² and MSB = SSB ÷ (k − 1), where k is the number of groups.
Arrange each group’s raw observations in its own column or prepare a summary table containing group size and group mean. Confirm that blank cells and text values are not being counted as observations.
Calculate SSB and MSB from a group summary table in Excel
Use this method when you have, or can calculate, the size and mean of every ANOVA group.
For each group, subtract the grand mean from the group mean, square the difference, and multiply it by the group size. Add all group contributions to obtain SSB, then divide SSB by the between-groups degrees of freedom, k − 1, to obtain MSB.
In an empty area of the worksheet, create headings such as Group, Size (n), Group Mean, and SSB Contribution. Enter one row for each group.
For a group stored in A2:A11, enter =COUNT(A2:A11) for its size and =AVERAGE(A2:A11) for its mean. Repeat for every group column or enter the known summary values.
Use the mean of all raw observations, such as =AVERAGE(A2:C11) when all groups are in columns A through C. If you only have group sizes and means, use =SUMPRODUCT(B2:B4,C2:C4)/SUM(B2:B4), where B contains sizes and C contains group means.
If the group size is in B2, group mean is in C2, and the grand mean is in F2, enter =B2*(C2-$F$2)^2 in the SSB Contribution column. Fill the formula down for all groups.
Sum the contribution cells with =SUM(D2:D4) to get SSB. If there are three groups, calculate MSB with =D5/(COUNT(B2:B4)-1), or divide SSB directly by k−1.

Use SUMPRODUCT to calculate SSB from sizes and means
Use this compact formula when group sizes and group means are already listed in adjacent cells.
Calculate One-Way ANOVA Between-Groups Values with WPS Spreadsheets
WPS Spreadsheets lets you calculate group counts, averages, weighted grand means, SSB, and MSB with familiar spreadsheet formulas. Enter your group data or summary statistics, then use COUNT, AVERAGE, SUM, and SUMPRODUCT to build an auditable ANOVA calculation table.
- 1. Open the data in WPS Spreadsheets: Open WPS Office, select Spreadsheets, and open the workbook containing the group observations or create a new worksheet.
- 2. Calculate group sizes and means: Select summary cells and enter formulas such as =COUNT(A2:A11) and =AVERAGE(A2:A11) for each group.
- 3. Calculate the weighted grand mean: In a result cell, enter =SUMPRODUCT(group_size_range,group_mean_range)/SUM(group_size_range) using your summary-table ranges.
- 4. Calculate SSB contributions: In the contribution column, enter =GroupSize*(GroupMean-GrandMean)^2 and use the fill handle to copy the formula to each group.
- 5. Return SSB and MSB: Use =SUM(contribution_range) for SSB, then divide that result by the number of groups minus 1 for MSB.

Frequently Asked Questions
What is the formula for sum of squares between groups in a one-way ANOVA?
Use SSB = Σ nᵢ(meanᵢ − grand mean)². For every group, multiply its sample size by the squared difference between its mean and the grand mean, then add the results.
How do I calculate the grand mean when group sizes are different?
Use a weighted mean, not a simple average of the group means. In Excel, enter =SUMPRODUCT(size_range,mean_range)/SUM(size_range).
What degrees of freedom should I use for mean square between groups?
Use k − 1, where k is the number of groups included in the one-way ANOVA. For example, four groups have 3 between-groups degrees of freedom.
Can I calculate SSB directly from group means and sample sizes?
Yes. If sizes are in B2:B4, means are in C2:C4, and the grand mean is in F2, use =SUMPRODUCT(B2:B4,(C2:C4-$F$2)^2).
Why is my SSB result zero or unexpectedly small?
Check that the grand mean references all observations or uses the weighted formula, and ensure the group size cells contain numeric counts rather than blank or text values.




