Is the Sum of Averages Equal to the Average of Sums
No, not as a blanket rule. The average of sums equals the sum of averages when you are summing one dimension of the same complete data set and averaging across the same observations with the same weights. But an average of averages, or a sum of averages from unequal-size groups, can produce a different and misleading result.
This distinction comes up in SQL reports, analytics dashboards, batch metrics, and any table organized by periods and categories. The key is to identify what each average represents and what denominator it used.
What the Two Calculations Mean
An arithmetic average, or mean, is:
\[ \text{average} = \frac{\text{sum of values}}{\text{number of values}} \]
Suppose a table has one row per year and one column per month. Let \(x_{ij}\) mean the value in year \(i\) and month \(j\).
You can calculate a typical annual total in two orders:
- Add each year’s monthly values, then average those annual totals.
- Average each month across the years, then add the monthly averages.
Those are different-looking operations, but they give the same result when every month is calculated across the same set of years.
The terms are easy to mix up:
- Average of sums: Find a total for each group, then average the group totals.
- Sum of averages: Find an average for each category, then add those averages.
- Average of averages: Find an average for each group, then average those group averages.
- Weighted average: Combine group averages while accounting for the number of records in each group.
The first two can be equal. The third often is not the overall average unless every group has the same number of observations.
How to Calculate the Right Result
Choose the calculation based on the question you need to answer.
| Your Question | Calculation to Use | Important Condition |
|---|---|---|
| What is the average total per year, user, request, or batch? | Average the totals for each group | Each group total must cover comparable components |
| Can I add average monthly values to get an average annual total? | Sum the monthly averages | Every monthly average must use the same years and weights |
| What is the average across all individual records? | Use a weighted average of group means | Keep each group’s record count |
| What is the typical total using a median? | Find each group total, then take the median | Do not add component medians |
Step 1: Define the Grouping and the Unit
First, identify the two dimensions in your data.
For example:
- Rows: calendar years
- Columns: months
- Cell value: monthly support tickets
- Row sum: annual support tickets
- Column average: average tickets for that month across all years
Then check that the values are actually additive. Monthly revenue can be added into annual revenue. Monthly request counts can be added into annual request counts. But overlapping user counts require additional context before they can be added.
Also decide how to treat missing values before calculating anything. A blank month, a zero month, and an unavailable month are different data states.
Step 2: Use the Formula That Matches the Question
For a rectangular data table with \(n\) rows and \(m\) columns, the average of the row sums is:
\[ \frac{1}{n}\sum_{i=1}^{n}\left(\sum_{j=1}^{m}x_{ij}\right) \]
The sum of the column averages is:
\[ \sum_{j=1}^{m}\left(\frac{1}{n}\sum_{i=1}^{n}x_{ij}\right) \]
Because addition can be rearranged, these expressions are equal:
\[ \frac{1}{n}\sum_{i=1}^{n}\sum_{j=1}^{m}x_{ij} = \sum_{j=1}^{m}\frac{1}{n}\sum_{i=1}^{n}x_{ij} \]
This is not a special shortcut. It is the same total divided by the same number of rows.
Step 3: Check Both Paths With a Small Example
Consider monthly values for three years:
| Year | January | February | Annual Total |
|---|---|---|---|
| Year 1 | 10 | 20 | 30 |
| Year 2 | 15 | 25 | 40 |
| Year 3 | 5 | 30 | 35 |
Average the annual totals:
The average annual total is \[ \frac{30 + 40 + 35}{3} = 35 \]
Now average each month and add those results:
\[ \text{January average} = \frac{10 + 15 + 5}{3} = 10 \]
The February average is \[ \frac{20 + 25 + 30}{3} = 25 \]
Adding the two monthly averages gives \[ 10 + 25 = 35 \]
Both methods produce 35 because every monthly average uses the same three years.
Finish the calculation by documenting the data grain, the denominator, and the missing-data rule. Those details determine whether a future query or dashboard still represents the same metric.
When the Equality Holds
Changing the order is safe only when both operations use the same complete data grid and weighting scheme.
The identity works when all of these are true:
- Each row contains the same categories.
- Each category average uses the same set of rows.
- The values can meaningfully be added.
- Every row has the same weight, or the same explicit weights are used in both methods.
The NOAA water-year table states this exact relationship for annual totals and monthly data: “Average of annual sums = Sum of monthly averages.”
For example, if you average January through December values across the same water years, adding those twelve monthly averages gives the average annual total for those water years.
The rule also works with fixed weights. If one year should count twice as much as another, use that same weighting system in every monthly average and in the final average of annual totals. What breaks the equality is changing the denominator or weighting system between the two routes.
Why an Average of Averages Can Be Wrong
An average of averages gives every group equal influence, even if the groups contain very different numbers of records.
Suppose one service has two response times with a mean of 3, while another has four response times with a mean of 9.
A plain average of the two service means is:
The unweighted average of the two service means is \[ \frac{3 + 9}{2} = 6 \]
Weighting each service mean by its response-time count gives the combined mean across all six response times:
The weighted calculation is \[ \frac{(2 \times 3) + (4 \times 9)}{2 + 4} = 7 \]
The correct combined mean is 7 because the second service contributed twice as many observations.
Use a weighted average when you have group means and group sizes:
The formula for the weighted overall mean is \[ \text{overall mean} = \frac{\sum_{g=1}^{k}n_g\bar{x}_g} {\sum_{g=1}^{k}n_g} \]
Where:
- \(n_g\) is the number of records in group \(g\)
- \(\bar{x}_g\) is that group’s mean
A plain average of averages is valid only when all groups have equal counts or when you intentionally want every group, rather than every record, to have equal influence.
The same principle applies to rates. To combine weekly conversion rates, calculate total conversions divided by total opportunities. Averaging weekly percentages gives each week equal influence, regardless of traffic volume.
Cases Where the Rule Changes
The rule changes for medians, missing values with different denominators, and measures whose sums and averages have different units.
Medians Do Not Follow This Rule
The NOAA water-year analysis gives the needed warning: “Median of annual sums DOES NOT EQUAL Sum of monthly medians.”
For example, consider two monthly columns across three years:
- First month: 0, 100, 100
- Second month: 100, 0, 100
The monthly medians are 100 and 100, which sum to 200.
For those three years, the annual totals are 100, 100, and 200. Their median is 100, not 200.
If you need a median annual total, calculate annual totals first and then take their median.
Missing Values Change the Denominator
Most analytics tools treat missing values differently from zeros. For example, SQL AVG() usually ignores NULL, meaning one monthly average may be based on more years than another.
That breaks the annual-total identity. A January average based on five years plus a February average based on four years is not necessarily the same as an average of complete annual totals.
Before comparing the two methods, verify that:
- each period has one record per category;
- no categories were silently dropped;
- duplicate rows were not counted twice; and
- all averages use the same set of groups.
If incomplete records are expected, build complete group totals explicitly or define a weighting and missing-data policy that matches the metric’s purpose.
Sums and Averages Have Different Units
A sum grows as you add more values. An average does not.
For example:
- A sum of daily request counts is a request count over a longer period.
- An average of daily request counts is requests per day.
- A sum of average monthly values can represent an average annual count when the monthly values are additive.
Always read the unit after the calculation, not just the number.
How to Verify an Aggregation in Code
For a complete numeric matrix, test both paths directly. In NumPy, rows can represent years and columns can represent months or other additive components.
import numpy as np
values = np.array([
[10, 20],
[15, 25],
[5, 30],
], dtype=float)
average_of_sums = values.sum(axis=1).mean()
sum_of_averages = values.mean(axis=0).sum()
assert np.isclose(average_of_sums, sum_of_averages)
print(average_of_sums) # 35.0
The equality is a useful data-quality check. If the values should form a complete year-by-month table but the two paths differ, inspect the data shape, missing values, filtering, and grouping keys.
In SQL, calculate each route in a separate aggregation:
WITH per_year AS (
SELECT
period_year,
SUM(value) AS annual_total
FROM measurements
GROUP BY period_year
)
SELECT AVG(annual_total) AS average_annual_total
FROM per_year;
WITH per_month AS (
SELECT
month_num,
AVG(value) AS monthly_average
FROM measurements
GROUP BY month_num
)
SELECT SUM(monthly_average) AS sum_of_monthly_averages
FROM per_month;
These queries should agree only when measurements contains the same complete set of years for every month. If a filter removes a year from one month but not another, the results answer different questions.
Frequently Asked Questions
Are sum and average the same?
No. A sum is the total of all values, while an average is that total divided by a count. A sum of 120 requests and an average of 120 requests per day describe very different quantities.
Can You Sum Averages?
Yes, when the averaged components are additive and every average uses the same population or period set. For example, summing average monthly counts can produce an average annual count when every month is averaged across the same years. Do not use this shortcut for percentages, rates with different denominators, or medians.
What Does Weighted Average Mean?
A weighted average gives larger groups more influence than smaller groups. Its formula is \(\sum n_g\bar{x}_g \div \sum n_g\), where each group mean is multiplied by its record count. Use it to combine averages from groups with unequal numbers of observations.
Is an Average of Averages the Same as the Overall Average?
Only when every subgroup contains the same number of observations. If groups have unequal sizes, a plain average of their means gives each group equal influence rather than each individual record equal influence. Use a weighted average to recover the overall mean.
Should a Logit Use an Average or a Sum?
Neither is universally correct. A sum is appropriate for logits that represent additive model evidence, such as log-likelihood contributions. A mean is appropriate when the result needs a scale that does not change as the number of items changes. For batch losses in machine learning, changing from a sum reduction to a mean reduction changes gradient scale by batch size, so the choice must match the training objective and learning-rate setup.
What Is the Formula for Calculating an Average?
The arithmetic average is the sum of the values divided by the number of values: \(\bar{x} = \sum x_i / n\). Before using it in code or a report, write down what \(n\) counts, raw records, periods, groups, or total weight, so the result has the intended meaning.
