Averages..problem with 0s...can you please help!

Bytes37

New Member
Joined
Mar 7, 2003
Messages
20
I have a column with values in it. Some are 0s and some values are not. If I average the column, it gives me the average of all the values including the 0s. How do I make excel not count the 0s in computing an average?

Thanks!
 

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.
It may not be simple, but...
Add a column with the formula;
=IF(datacell=0,"nil","excludes nil") Call the column "Flag"
Create a pivot table and drag your data into the data part of the wizard. Drag the new column "Flag" to the page part of the wizard, select finish.

If you select "excludes nil" from the dropdown next to "Flag" you'll get your answer.

Good luck
 
Upvote 0
If you only have positve numbers, you could use
=SUM(A1:A10)/COUNTIF(A1:A10,">0")

otherwise array enter (control shift enter)
=AVERAGE(IF(A1:A4,A1:A4))

good luck
 
Upvote 0
Hi,

Assuming the range of wich you want to compute the average is A1:A10,
you can try this Array Formula:

{=SUM(IF(NOT(A1:A10),0,A1:A10))/COUNTIF(A1:A10,"<>0")}

Hope this helps.
 
Upvote 0
Hi,
You can also use these;

Average contiguous cells containing zeros

SUM(range)/MAX(1,COUNT(range)-COUNTIF(range,0))

Average noncontiguous cells containing zeros

SUM(range)/COUNTIF(range,">"&0)

Hope this helps, 2rrs
 
Upvote 0
Howdy,

2rrs said:
Average noncontiguous cells containing zeros
SUM(range)/COUNTIF(range,">"&0)

I don't think you can use countif on a noncontiguous range. But you can use something like this.
 
Upvote 0
Right Paddy, nice catch. Actually I had seen this here. I should have said, like as quoted... But yes, nice link Paddy, and I should consider my words a little more wisely...
 
Upvote 0
Just for variety, the following non-array could also be used for positive and negative in a contiiguous range:
=SUM(A1:A10)/MAX(1,SUM(COUNTIF(A1:A10,{">0","<0"})))
 
Upvote 0

Forum statistics

Threads
1,214,797
Messages
6,121,629
Members
449,041
Latest member
Postman24

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