Weited Avg exlcuding negative and zero value

dennisli

Well-known Member
Joined
Feb 20, 2004
Messages
1,070
Let’s say a formula: =Sum(B1:B50)/Sum(A1:A50).
If there are any negatives or zero in B1:B50 or A1:A50, that record does not include in the calculation. For example, if A10 is -10 or 0, then A10 and B10 will be counted out even B10 is a positive number. Similarly, if B10 is -10 or 0, then A10 and B10 will be counted out even A10 is a positive number.
Thanks lot.
Dennis
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,782
Office Version
  1. 2010
Platform
  1. Windows
This is a guess as to what you want:

=SUMPRODUCT((A1:A50>0)*(B1:B50>0), B1:B50) / SUMPRODUCT((A1:A50>0)*(B1:B50>0), A1:A50)
 

dennisli

Well-known Member
Joined
Feb 20, 2004
Messages
1,070
Thank you.
I am not sure whether I have posted before:
Suppose the date from row 1 to row 10 is for years 2000 to 2010. I want to average the latest three years positive results. In other words, first use A8:A10 data. If there are any positive or zero data, check range A7:B7, then A6:B6, until three pairs of positive data are found and get the average.
Appreciate your help.
Dennis
 

Watch MrExcel Video

Forum statistics

Threads
1,123,304
Messages
5,600,865
Members
414,409
Latest member
FloordAlex

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
Top