SOLVED

finding the everage from a column of numbers but ignoring the cells in which the value is zero

%3CLINGO-SUB%20id%3D%22lingo-sub-1774297%22%20slang%3D%22en-US%22%3Efinding%20the%20everage%20from%20a%20column%20of%20numbers%20but%20ignoring%20the%20cells%20in%20which%20the%20value%20is%20zero%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1774297%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20How%20do%20I%20find%20the%20average%20of%20a%20column%20of%20cells%2C%20while%20ignoring%20the%20cells%20in%20which%20the%20value%20is%20zero%3F%20Let's%20say%203%20out%20of%206%20cells%20which%20are%20under%20the%20average%20formula%20have%20a%20zero%20value%2C%20then%20I%20want%20Excel%20to%20average%20only%20the%20other%20three%20cells%20which%20have%20a%20value.%20just%20to%20make%20it%20clear%3A%20if%20the%20column%20of%20cells%20under%20the%20formula%20are%3A%202%2C%200%2C%202%2C%200%2C%202%2C%200%20-%20then%20the%20average%20result%20should%20be%202%3C%2FP%3E%3CP%3EThanks%20in%20advance%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1774297%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1774327%22%20slang%3D%22en-US%22%3ERe%3A%20finding%20the%20everage%20from%20a%20column%20of%20numbers%20but%20ignoring%20the%20cells%20in%20which%20the%20value%20is%20zero%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1774327%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F830227%22%20target%3D%22_blank%22%3E%40meirtu%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPerhaps%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DAVERAGEIF(A1%3AA6%2C%22%26lt%3B%26gt%3B0%22)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1774405%22%20slang%3D%22en-US%22%3ERe%3A%20finding%20the%20everage%20from%20a%20column%20of%20numbers%20but%20ignoring%20the%20cells%20in%20which%20the%20value%20is%20zero%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1774405%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3EThanks!!%20this%20works%20great!!%20why%20should%20there%20be%20a%20coma%20before%20the%20quotation%20marks%20in%20the%20formula%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1774643%22%20slang%3D%22en-US%22%3ERe%3A%20finding%20the%20everage%20from%20a%20column%20of%20numbers%20but%20ignoring%20the%20cells%20in%20which%20the%20value%20is%20zero%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1774643%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F830227%22%20target%3D%22_blank%22%3E%40meirtu%3C%2FA%3E%26nbsp%3B%2C%20you%20are%20welcome.%3C%2FP%3E%0A%3CP%3EIt%20separates%20second%20parameter%20which%20defines%20criteria%2C%20please%20see%20here%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Faverageif-function-faec8e2e-0dec-4308-af69-f5576d8ac642%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAVERAGEIF%20function%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1777953%22%20slang%3D%22en-US%22%3ERe%3A%20finding%20the%20everage%20from%20a%20column%20of%20numbers%20but%20ignoring%20the%20cells%20in%20which%20the%20value%20is%20zero%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1777953%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3EThanks%20Sergei!%20I%20will%20definitely%20carefully%20read%20the%20tutorial%20link%20you%20sent%20me%20to%20better%20understand%20this%20wonderful%20formula%2C%20and%20also%20read%20about%20some%20other%20formulas%20which%20are%20not%20clear%20to%20me.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1778045%22%20slang%3D%22en-US%22%3ERe%3A%20finding%20the%20everage%20from%20a%20column%20of%20numbers%20but%20ignoring%20the%20cells%20in%20which%20the%20value%20is%20zero%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1778045%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3EHi%20again.%20actually%20checking%20again%2C%20this%20formula%20does%20not%20work!%20it%20does%20not%20work%20because%20in%20some%20of%20the%20percentage%20cells%20in%20the%20column%20there%20is%20an%20%23DIV%2F0!%20error.%20This%20error%20appears%20because%20the%20sums%20in%20some%20of%20the%20cells%20on%20which%20the%20percentage%20has%20to%20be%20calculated%20have%20not%20been%20fed%20yet%2C%20and%20will%20only%20be%20fed%20as%20the%20year%20proceeds%20(it's%20a%20monthly%20interest%20percentage%20calculation).%20Is%20there%20a%20possibility%20of%20calculating%20the%20percentage%20in%20the%20percentages%20column%20without%20dividing%3F%20Because%20division%20will%20allways%20result%20in%20division%20of%20zero%20until%20all%20the%20cells%20are%20fed.%20Or%20maybe%20some%20other%20solution%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi, How do I find the average of a column of cells, while ignoring the cells in which the value is zero? Let's say 3 out of 6 cells which are under the average formula have a zero value, then I want Excel to average only the other three cells which have a value. just to make it clear: if the column of cells under the formula are: 2, 0, 2, 0, 2, 0 - then the average result should be 2

Thanks in advance

11 Replies
Highlighted
Best Response confirmed by meirtu (Occasional Contributor)
Highlighted

@Sergei BaklanThanks!! this works great!! why should there be a coma before the quotation marks in the formula?

Highlighted

@meirtu , you are welcome.

It separates second parameter which defines criteria, please see here AVERAGEIF function 

Highlighted

@Sergei BaklanThanks Sergei! I will definitely carefully read the tutorial link you sent me to better understand this wonderful formula, and also read about some other formulas which are not clear to me.

Highlighted

@Sergei BaklanHi again. actually checking again, this formula does not work! it does not work because in some of the percentage cells in the column there is an #DIV/0! error. This error appears because the sums in some of the cells on which the percentage has to be calculated have not been fed yet, and will only be fed as the year proceeds (it's a monthly interest percentage calculation). Is there a possibility of calculating the percentage in the percentages column without dividing? Because division will allways result in division of zero until all the cells are fed. Or maybe some other solution

 

Thanks in advance

Highlighted

@meirtu 

You may wrap it by IFERROR returning in case of error empty text or any other value you prefer

=IFERROR(AVERAGEIF(A1:A6,"<>0"),"")

 

Highlighted

@Sergei BaklanThanks, but for some reason it still is not working. The formula yields no result.

I am sending you the actual sheet after writing the formula as you stated. If you would be kind enough to look what is still preventing this from working, I would be so grateful. Please note that the sheet is laid from right to left, and the relevant formula is written in cell E14.

 

Thanks again

Highlighted

@meirtu 

Sorry, I misunderstood you, though entire formula returns an error (that happens if all cells are blank).

 

With errors inside the range there are several ways to avoid, couple of them:

image.png

for the column G formula is

=AVERAGEIFS(G2:G13,G2:G13,"<>0",G2:G13,"<>#DIV/0!")

which ignores both zeroes and this concrete error. 

But it will be much better if you clean your data within the range, in column H formulas are

=IFERROR(IF(D2,D2/B2,""),"")

which returns empty string if any of D2 or B2 is zero. Or, as variant in column I

=IF((D2=0)+(B2=0),"",D2/B2)

With that you may use simple AVERAGE, it ignores all texts

=AVERAGE(H2:H13)

 

Highlighted

@Sergei BaklanThanks Again! the first option you gave works wonderfully! I checked several times. I Prefer it to the second option you gave. Can I just ask about the first option why the range is repeated twice ate beginning? (G2:G13,G2:G13........)

Highlighted

@meirtu , you are welcome, glad to help.

 

Previous time was AVERAGEIF() function, here is another one, AVERAGEIFS function 

It requires separate ranges for each criteria and another one for the average itself.  AVERAGEIF uses only one range and one criteria.

 

Highlighted