![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Join Date: Mar 2003
Posts: 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! |
|
|
|
|
|
#2 |
|
Join Date: Nov 2002
Location: Brisneyland, Australia
Posts: 275
|
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 |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
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 |
|
|
|
|
|
#4 |
|
Join Date: Dec 2002
Location: Larache--Morocco
Posts: 2,896
|
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.
__________________
Jaafar. Happiness is when what you think, what you say, and what you do are in harmony. http://www.laracheenelmundo.com/ |
|
|
|
|
|
#5 |
|
Join Date: Dec 2002
Posts: 346
|
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 |
|
|
|
|
|
#6 | |
|
MrExcel MVP
Admin Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,617
|
Howdy,
Quote:
|
|
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: May 2002
Posts: 12,554
|
Hi Nate
Takes a bit of work, but you can use countif on non-contiguous ranges: http://www.mrexcel.com/board2/viewto...=136110#136110 whether you'd want to is another matter! paddy |
|
|
|
|
|
#9 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
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"}))) |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|