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?
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.
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...
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"})))
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.