SUMPRODUCT/SUM with criteria

XcelLearner

Board Regular
Joined
Feb 6, 2016
Messages
52
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a portfolio with hundred of stocks, but for simplicity, let's say I have three stocks, with their respective PERs and market caps:

PERMarket Cap
ABC15150
DEF10101
XYZ1280
Market-cap-weighted average12.99x
Formula?

<tbody>
</tbody>


I would like to take a market-cap-weighted PER for the entire portfolio, and the formula would be "SUMPRODUCT(B2:B5,C2:C5)/SUM(C2:C5)".

Suddenly, I want to have a market-cap-weighted PER for a portfolio of stocks with their market caps larger than 100. The result should be 12.99. However, I don't know how to revise the formula with condition of market cap >100.

Could you please help? Thank you very much.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I setup my table like this:

ABC
1StockPerMktCap
2ABC15150
3DEF10101
4XYZ1280
Weighted PER12.98805

<tbody>
</tbody>

Here is the formula I came up with:

Code:
{ =SUM(IF(C2:C4>100,B2:B4)*IF(C2:C4>100,C2:C4))/SUMIF(C2:C4,">100") }
 
Upvote 0
try this out

=SUMPRODUCT(B2:B4,--(C2:C4>100),C2:C4)/SUMIF(C2:C4,">100",C2:C4)

EDIT: woops i see people beat me to it lol should have refreshed
 
Last edited:
Upvote 0
I setup my table like this:

ABC
1StockPerMktCap
2ABC15150
3DEF10101
4XYZ1280
Weighted PER12.98805

<tbody>
</tbody>

Here is the formula I came up with:

Code:
{ =SUM(IF(C2:C4>100,B2:B4)*IF(C2:C4>100,C2:C4))/SUMIF(C2:C4,">100") }
Hi, how should I revise the formula if I want to have several criterion, such as:
market cap >100 and
PER > 10

Thanks.
 
Upvote 0
You’d need to incorporate and AND with the IFs and change SUMIF to SUMIFs. I will try and get the exact syntax for you soon.
 
Upvote 0
Hi, how should I revise the formula if I want to have several criterion, such as:
market cap >100 and
PER > 10

Thanks.
An array-processing formula with SUMPRODUCT...

=SUMPRODUCT(--(cap>100),--(per>10),B2:B4,C2:C4)/SUMIFS(cap,per,">10",cap,">100")

or an array-processing formula with SUM and IF...

=SUM(IF(cap>100,IF(per>10,cap*per)))/SUM(IF(cap>10,IF(per>10,cap)))


The latter requires confirming with control+shift+enter, not just enter:




=SUMPRODUCT(
 
Upvote 0

Forum statistics

Threads
1,215,563
Messages
6,125,572
Members
449,237
Latest member
Chase S

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