Investing

How to Calculate Weighted Average: Formula and Investing Examples

Learn how to calculate weighted average using shares, portfolio values, or group sizes, with worked examples and a warning about US stock tax basis.

Illustration of a balance scale with unequal coin stacks beside a worksheet and calculator

Information checked November 3, 2026. All examples are hypothetical, not market data or investment recommendations. The arithmetic applies generally; the tax caveat is US-specific.

Here is how to calculate weighted average: multiply each value by its corresponding weight, add those products, and divide by the sum of the weights. A weight tells you how much each observation should count toward the answer.

The NIST definition of the weighted mean supplies that calculation. For investors, the important decision comes first: are you averaging purchase prices, returns across holdings, or percentages across groups? Each question needs a different weight.

Choose the weight that matches the question

A simple average gives every listed observation equal influence. That makes sense when each represents the same amount. It can mislead when a small purchase counts as much as a much larger one.

Your question Value to average Appropriate weight
Average purchase price for the same security Price per share Shares bought at that price
Return across static holdings for one period Each holding’s period return Beginning market value
Combined percentage across comparable groups Each group’s percentage Its underlying group size

These applications follow the weighted-mean formula and the units involved. The portfolio case below has additional assumptions. Weighting does not make unrelated numbers comparable or guarantee a more useful forecast.

For a different use of weights, our earnings-per-share guide shows how long shares were outstanding affects a company’s EPS calculation.

How to calculate weighted average in four steps

  1. Identify the values and their weights. Keep each pair together and use compatible units.
  2. Multiply each pair. For a share purchase, shares multiplied by price gives dollars paid.
  3. Add the products and separately add the weights. Do not divide by the number of rows unless rows genuinely have equal weights.
  4. Divide the product total by the weight total. Keep precision until the final rounding.

With nonnegative weights and a positive total, the answer must fall between the smallest and largest values. That is a useful error check, not proof that you chose the right weights. If all weights are zero, division is undefined. Signed weights, short positions, and leverage are outside this introductory method.

Example 1: average purchase price per share

Suppose you buy the same stock twice, with no fees, sales, splits, or other adjustments:

Buy Shares Price Paid
First 3 $20 $60
Second 7 $40 $280
Total 10 — $340

Average purchase price is $340 ÷ 10 = $34 per share. The dollar check is 10 × $34 = $340.

The simple average of the two prices is ($20 + $40) ÷ 2 = $30. That describes two equally weighted order prices, not what you paid per share. Because you bought more shares at $40, the correct purchase-price average is closer to $40.

Do not weight this example by each order’s dollar amount instead. Price multiplied by dollars and divided by dollars answers a different weighting question; shares are the units you are averaging the purchase cost over.

US tax caveat: this is not a universal cost-basis method

The IRS stock-basis FAQ says average basis generally cannot be used to determine gain or loss on stock sales, except for certain mutual fund shares and certain dividend reinvestment plans. Purchase costs and other adjustments can also affect basis.

The IRS separately describes an average-basis election for eligible mutual fund shares. The $34 figure above is a descriptive purchase-price average, not permission to use $34 as the basis of any shares you later sell. Keep the actual tax-lot records.

Example 2: a portfolio with unequal holdings

Assume you hold two investments over exactly the same period. There are no contributions, withdrawals, trades, rebalancing, income payments, fees, or taxes during that period. Both are measured in dollars.

  • Holding A begins at $7,000 and gains 12%, earning $840.
  • Holding B begins at $3,000 and loses 4%, losing $120.
  • Beginning portfolio value is $10,000, so the starting weights are 70% and 30%.

Multiply 0.70 × 12% and 0.30 × −4%. The contributions are 8.4 and −1.2 percentage points, giving a 7.2% portfolio return.

Check it through dollars: $840 − $120 = $720 gained; $720 ÷ $10,000 × 100 = 7.2%. Ending value is $10,720. A simple average of 12% and −4% gives 4%, which is not this portfolio’s return.

Why beginning values? Each holding’s gain equals its starting value multiplied by its return. Adding those gains and dividing by the portfolio’s starting value produces the weighted result. Ending weights already reflect performance and do not give the same calculation.

FINRA’s performance guide explains that investment return includes value changes and income, with costs taken into account. Real portfolios need those items handled consistently. The stripped-down example excludes them to isolate the weighting. If money moves in or out or you trade during the period, use a performance method appropriate to that activity rather than treating deposits as investment gains.

Percentages need the right denominator

Suppose two separate groups answer the same yes-or-no question. In the first, 2 of 100 say yes: 2%. In the second, 72 of 900 say yes: 8%.

Together, 74 of 1,000 say yes, so the combined proportion is 7.4%, not the simple average of 5%. Group sizes are the weights because they are the denominators behind the percentages. This is the same multiply-add-divide identity, not a rule for averaging unrelated rates such as a loan APR and a stock yield.

Weights also need consistent formatting. Fractions 0.70 and 0.30 sum to 1; whole-number weights 70 and 30 sum to 100. Both produce the same weighted mean if you divide by their respective sums. Mixing 70 with 0.30 does not represent a 70/30 split.

A spreadsheet shortcut

For numeric values in A2:A3 and their weights in B2:B3, the formula =SUMPRODUCT(A2:A3,B2:B3)/SUM(B2:B3) implements the same steps. Keep the ranges aligned and check the positive denominator. In the stock example, enter 20 and 40 as values and 3 and 7 as weights: the arithmetic gives 34. This is a formula illustration, not a tested downloadable workbook.

Weighting across holdings is not compounding across time

One investment gaining 20% and then losing 20% does not break even. Starting with $100, the path is $100 × 1.20 × 0.80 = $96, a 4% total loss. Those are consecutive periods, not simultaneous holdings with allocation weights.

Use our compound-interest calculator to explore a constant-rate illustration, while remembering that actual investment returns vary. Our index-fund introduction provides context for investing through pooled holdings; weighting arithmetic alone does not measure risk or tell you which fund to buy.

Conclusion: start with what each number represents

Knowing how to calculate weighted average means more than multiplying and dividing. Choose weights that match the question, preserve units and time periods, and reconcile the result against total dollars or observations. Keep purchase-price summaries separate from tax accounting, and same-period portfolio weighting separate from multi-period compounding.

Frequently Asked Questions

Do weights have to add up to 100%?

No. Counts or relative weights can total any positive amount; divide by that actual total. But if you intend to describe an entire portfolio using allocation percentages, investigate a total below or above 100%. Normalizing an incomplete list describes the included holdings, not necessarily your whole portfolio.

What happens if all my weights are zero?

The denominator is zero, so this weighted mean is undefined. Do not report zero as the answer. Check whether you omitted the observations or entered the wrong weights. This tutorial uses nonnegative weights with at least one positive weight; leveraged and short-position calculations need separate treatment.

When does a simple average give the same result?

Equal weights make a weighted mean reduce to the ordinary average. For example, equal numbers of shares bought at two prices make the simple average of those prices valid. Unequal weights can also happen to produce the same numerical result, but that coincidence does not make the methods interchangeable.

Can I average annual returns to find my total investment gain?

Not by treating consecutive years as simultaneous holdings. Without cash flows, sequential returns compound: a 20% gain followed by a 20% loss leaves $100 at $96, a 4% loss overall. The weighted portfolio example instead combines different holdings over one common period under stated assumptions.

Can I use average purchase price to calculate US tax gains on every stock sale?

No. The IRS generally does not permit average basis for ordinary stock sales, except for certain mutual fund shares and certain dividend reinvestment plans. Specific-share identification, applicable default rules, adjustments, and any eligible election matter. Use your tax-lot records and appropriate tax guidance, not just this purchase-price summary.

Disclaimer: This article is for educational purposes only and is not financial advice. Consider your own situation and speak with a qualified professional before making financial decisions. How we write and review content.

Written by

FinTechAi Editorial Team

Research & Editorial

The FinTechAi editorial team researches, writes and fact-checks every guide on investing, crypto, AI, banking and personal finance.