Average cells >0

Tikey

Board Regular
Joined
Jan 30, 2014
Messages
148
Office Version
  1. 2021
Platform
  1. Windows
Hi

I wish to average a number of cells, but only if all the cells in the range are >0. I have tried using =AVERAGEIF(A1:A5 ,">0"), but this includes any odd cells that are >0 and in the first example below, gives an answer of 3 when it should be 0. The second example shows the result should only be when all values are > 0.

AA
1​
0​
1​
2​
2​
0​
2​
2​
3​
0​
3​
2​
4​
0​
4​
2​
5​
3​
5​
2​
Answer Required
0​
2​
Maybe this should be easy, but I cannot find a solution, any help appreciated.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
perhaps
= IF ( Countif(A1:A5, 0)>0, "" , Average(A1:A5) )
 
Upvote 0
Hi there. Does this do the job? NB The formulas are array formula so need entering with ctrl-shift-enter.
Book3 (version 1).xlsb
AB
110
220
330
440
553
630
Sheet3
Cell Formulas
RangeFormula
A6:B6A6=IF(A1:A5>0,AVERAGE(A1:A5),0)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
etaf

Thanks for your reply, this works but does not display the 0 in the answer as in my example 1. Maybe I'm doing something wrong.
 
Upvote 0
jmacleary

Thanks for your reply, unfortunately this appears to still provide an average when one of the cells is 0.
 
Upvote 0
Not wishing to steal etaf's thunder but just swap out the "" with 0

ie
= IF ( Countif(A1:A5, 0)>0, 0 , Average(A1:A5) )
 
Upvote 0
jmacleary

Thanks for your reply, unfortunately this appears to still provide an average when one of the cells is 0.
Yes, you're right - I didn't test it properly. You can use etaf's answer slightly modified like:
=IF(COUNTIF(A1:A5,0)>0,0,AVERAGE(A1:A5))
to get the zeroes you want.
 
Upvote 0
Everyone, thanks all your replies, problem sorted, much appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

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