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
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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)
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,524
Messages
6,114,117
Members
448,549
Latest member
brianhfield

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