
Dan Patiño
AI Strategy & Innovation at Coderhouse
Data
A weighted average is an average in which some values count more than others. Each value is multiplied by a weight that reflects its importance or size, the results are added up, and the total is divided by the sum of the weights. When all weights are equal, the weighted average is the same as the ordinary mean.
It matters because many of the numbers analysts report are already averages or rates: average order value by store, conversion rate by campaign, satisfaction score by region. Averaging those numbers again with a simple mean gives small groups the same influence as large ones, and the result can be badly wrong. Knowing when to weight, and by what, is one of the most practical skills in everyday data analysis.
The weighted average formula
The formula for the weighted arithmetic mean is:
Weighted average = (w1x1 + w2x2 + … + wnxn) / (w1 + w2 + … + wn)
Here x is each value and w is its weight. Weights can be percentages that add up to 100%, or raw counts such as orders, users or units sold. Dividing by the sum of the weights is what makes both cases work.
A simple example: a course grade
Suppose homework is worth 20% of a grade, the midterm 30% and the final exam 50%. A student scores 90, 70 and 80.
Simple average: (90 + 70 + 80) / 3 = 80
Weighted average: 0.2 × 90 + 0.3 × 70 + 0.5 × 80 = 18 + 21 + 40 = 79
The weighted result is lower because the weakest score, the midterm, carries more weight than the strongest one, homework.
Why the simple average of averages misleads
The most common analyst mistake is averaging averages. Imagine two stores:
Store | Orders | Average order value | Revenue |
|---|---|---|---|
Store A | 100 | $50 | $5,000 |
Store B | 900 | $20 | $18,000 |
Total | 1,000 | $23,000 |
The simple average of the two order values is ($50 + $20) / 2 = $35. But the company's real average order value is $23,000 / 1,000 orders = $23. Weighting each store's value by its number of orders gives the correct answer: (100 × 50 + 900 × 20) / 1,000 = $23.
The same trap appears with rates. If campaign A converts 5% of 2,000 visitors (100 conversions) and campaign B converts 15% of 200 visitors (30 conversions), the average of the two rates is 10%, yet the true combined conversion rate is 130 / 2,200, about 5.9%. In extreme cases, comparing groups with very different sizes can even reverse a conclusion, a pattern known as Simpson's paradox.
Common uses of weighted averages in analytics
Combining segment metrics: overall conversion rate, churn rate or satisfaction score across regions, channels or plans, weighted by each segment's volume.
Weighted average price or cost: average selling price across products weighted by units sold, or inventory cost weighted by quantity purchased at each price. Investopedia's overview covers the finance uses, such as portfolio returns and weighted average cost of capital.
Scoring models: lead scores, vendor scorecards and prioritization matrices often combine criteria with different importance weights.
Survey weighting: adjusting responses so the sample better reflects the population, for example by age group or region.
Time series: a weighted moving average gives recent periods more influence than older ones.
How to calculate a weighted average in Excel, SQL and Python
Excel or Google Sheets
With values in B2:B10 and weights in C2:C10, use the SUMPRODUCT function:
=SUMPRODUCT(B2:B10, C2:C10) / SUM(C2:C10)
SQL
To get the overall average order value from a table of stores:
SELECT SUM(avg_order_value * orders) / SUM(orders) AS weighted_aov FROM store_summary;
Even better, when you have the raw data, compute the metric from totals: SUM(revenue) / SUM(orders). That avoids the problem entirely.
Python with pandas
weighted = (df["value"] * df["weight"]).sum() / df["weight"].sum()
NumPy offers the same calculation with np.average(df["value"], weights=df["weight"]).
How to choose the right weights
Use the denominator of the metric. Rates and averages should be weighted by what they were divided by: conversion rate by visitors, average order value by orders, average handle time by tickets.
Document judgment-based weights. In scorecards, weights are a business decision. Write them down and review them with stakeholders.
Check for missing data. A segment with no weight disappears from the result, which may hide a problem.
Watch dominant segments. If one segment carries most of the weight, report it separately as well, so smaller segments don't vanish from view.
Weighted average vs mean, median and mode
The simple mean treats every observation equally, and the median and mode describe the center of a distribution in other ways, as explained in this guide on mean vs median vs mode. A weighted average answers a different question: what is the typical value when each item should count in proportion to its size or importance?
FAQ
Do weights need to add up to 1 or 100%?
No. As long as you divide by the sum of the weights, you can use counts, revenue or any positive number.
When should I not use a weighted average?
When each item genuinely deserves equal influence, for example when comparing the typical performance of stores regardless of size. Then report the simple average, and say so.
Is a weighted average the same as calculating from totals?
For rates and ratios, yes: weighting each group's rate by its denominator gives the same result as dividing the overall numerator by the overall denominator.
Keep learning with Coderhouse
Getting averages right is part of turning data into decisions people can trust. Choose your next step:
Data Analytics Course — learn SQL, Python, statistics and AI-assisted analysis to build metrics that hold up; no coding background needed.
Forward Deployed AI Engineering Course — for engineers with production experience who want to build and evaluate AI systems inside real organizations.
GTM Engineer Course (waitlist) — join the waitlist to be the first to know when enrollment opens for the program on go-to-market engineering.
I'm Dan Patiño, head of AI Strategy & Innovation at Coderhouse. My day-to-day work involves merging the tactical management of e-commerce (CRO, Email Marketing and SEO) with the development of disruptive solutions. I specialize in building internal AI-powered apps to automate tasks and boost innovation within the team. I firmly believe that technology is strategy's best ally. To dive deeper into my professional journey, I'll be waiting for you on my LinkedIn profile.