Sumproduct weighted average with one condition

excelman2

New Member
Joined
Oct 2, 2011
Messages
2
Hi,

I've tried a few suggestions, but I cannot figure out how to add a condition to this formula: =SUMPRODUCT(G2:G100,F2:F100) / SUM(F2:F100) so that it will automatically recalculate when I add additional data. How I would rewrite it (but this doesn't work of course) is like this:

IF(c2:c100="GE"),SUMPRODUCT(G2:G100,F2:F100) / SUM(F2:F100)

I admit it, I'm not expert but thought that would help you see what I'm trying to do; I use the formula to calculate the weighted average of multiple stock purchases/dividend reinvesting of the same stock over time:

Column G: Stock Purchase Price
Column F: Number of Shares
Column C: Stock Ticker Symbol (GE for example); there are multiple stock tickers--not just GE.
Column C on a worksheet 2: Stock Ticker Symbol (GE for example)

Thank you in advance!:eeek:
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi and welcome to the board,

Maybe this

=SUMPRODUCT(--($C$2:$C$100="GE"),$F$2:$F$100,$G$2:$G$100)/SUMIF($C$2:$C$100,"GE",$F$2:$F$100)

Alternatively you can use a cell reference instead of hard coding the stock symbol.

HTH

M.
 
Upvote 0
Marcelo,

You're a genius! Thanks so much for the help and welcome; this has been driving me crazy and it works great in Excel. Sadly, I can't say the same for Google Docs, but I can export and import the data as a work around. Better than doing it by hand!

Tyler
 
Upvote 0
Marcelo,

You're a genius! Thanks so much for the help and welcome; this has been driving me crazy and it works great in Excel. Sadly, I can't say the same for Google Docs, but I can export and import the data as a work around. Better than doing it by hand!

Tyler

Tks for the feedback. Glad to help :)

M.
 
Upvote 0
I found this formula very helpful, it worked perfectly! However, I need one that can consider 3 criteria when determining which values to include in the weighted average calculation. Building on your previous example, lets assume the 2 additional criteria are in columns A and B
 
Upvote 0
If i'm understanding correctly what you need, maybe something like this

=SUMPRODUCT(--($A$2:$A$100="criteria1"),--($B$2:$B$100="criteria2"),--($C$2:$C$100="criteria3"),$F$2:$F$100,$G$2:$G$100)/
SUMIFS($F$2:$F$100,$A$2:$A$100,"criteria1",$B$2:$B$100,"criteria2",$C$2:$C$100,"criteria3")


Hope this helps

M.


 
Last edited:
Upvote 0
If i'm understanding correctly what you need, maybe something like this

=SUMPRODUCT(--($A$2:$A$100="criteria1"),--($B$2:$B$100="criteria2"),--($C$2:$C$100="criteria3"),$F$2:$F$100,$G$2:$G$100)/
SUMIFS($F$2:$F$100,$A$2:$A$100,"criteria1",$B$2:$B$100,"criteria2",$C$2:$C$100,"criteria3")


Hope this helps

M.


That really is a smart trick, thanks!
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top