Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: An Average that Excludes Zero Values.

An Average that Excludes Zero Values

by Allen Wyatt
(last updated September 9, 2016)

26

Veronica knows how to use the AVERAGE function to determine the average of a range of values. She would like to have the average determined based on the non-zero values in the range, however.

The worksheet function most suited to this purpose is to use AVERAGEIF. You can use it in this manner:

=AVERAGEIF(A1:A50,">0")

This function only includes in the average those cells that contain values greater than zero. If you want to also exclude blank cells, you should use the AVERAGEIFS function. This function differs from AVERAGEIF in that it allows you to specify multiple criteria that indicate which cells to average.

=AVERAGEIFS(A1:A50,A1:A50,">0",A1:A50,"<>""")

Of course, if you want to approach the problem "old school" (without using AVERAGEIF or AVERAGEIFS), then there are several ways you can proceed. The first is to remember how an average is calculated. It is defined as the sum of a range of values divided by the number of items in the range. Thus, you could figure the exclusionary average by simply making sure that the denominator (the number you are dividing by) does not include any zero values. For instance:

=SUM(A1:A50)/COUNTIF(A1:A50,"<>0")

This approach uses the COUNTIF function to determine the number of cells in the range (A1:A50) that don't contain zero. If this range contains not only zeros but also blank cells, and you don't want the blank cells figured into the result, then you need to use a more complex formula:

=SUM(A1:A50)/(COUNTIF(A1:A50,"<>0")-COUNTBLANK(A1:A50)-
(COUNTA(A1:A50)-COUNT(A1:A50)))

The COUNTIF function counts cells that do not explicitly evaluate to 0, but it will count blank and text cells. The COUNTBLANK term adjusts for the blank cells and the difference between COUNTA and COUNT adjusts the total count for cells that contain text.

Of course you can also use an array formula to do your calculation:

=AVERAGE(IF(A1:A50<>0,A1:A50))

Remember that array formulas need to be entered by using the combination Ctrl+Shift+Enter. This array formula also excludes blanks or cells containing text.

All in all it is easier to use the AVERAGEIF or AVERAGEIFS functions. When would you not want to use them? When you need to share your workbook with users of Excel versions prior to Excel 2007. (This is when the functions were added to Excel.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7729) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: An Average that Excludes Zero Values.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Getting Big Macros to Run

Troubleshooting an Excel macro when it causes the entire computer to freeze can be a tedious affair. This tip provides some ...

Discover More

Correctly Repeated Words

There are times when you need to repeat a word in a document, but doing so triggers an "error reaction" from Word's spelling ...

Discover More

Wrapping Text Around a Graphic

Place a graphic in your document, and you may want to make sure that your document text "wraps" around the edges of the ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

MORE EXCELTIPS (RIBBON)

Averaging a Non-Contiguous Range

Figuring out how to average data that is in a contiguous range of cells is easy. When the data is spread over a group of ...

Discover More

Averaging the Last Numbers in a Column

Need to calculate a running average for the last twelve values in a constantly changing range of values? The formula ...

Discover More

Excluding Values from Averaging

Calculating an average of a group of numbers is easy. What if you want to exclude a couple of the numbers from the group you ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 3?

2016-08-28 11:39:11

Larry K. Binning

I have a row of numbers that are added to each week. I need to calculate the average for the last 7 weeks excluding zeros or blanks when they occur and removing the max and min of the 7 numbers calculating the average on the 5 remaining numbers. Is there a convenient way to do this.

thanks
Larry


2016-06-11 05:45:58

Michael (Micky) Avidan

@Wendi,
It sounds as if your calculation have changed from "Automatic" to "manual".
(Check it according to your Excel version)
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
ISRAEL


2016-06-10 09:11:40

Wendi

I am trying to write a formula where you calculate the average, and excluding any blank or zero value cells, then take the average sum and subtract the lower amount from it to the sum total. This is for calculating cost savings. I've got the average part excluding the zero values (and as per your not above) hold the shift+cntrl+enter. BUT whenever I change a value in one of the cells, it does not update the value, I have to go back in and hold shift+cntrl+enter again. Help!


2016-05-24 11:04:34

Willy Vanhaelen

@Sharyn Kingston

Look in Excel's Help and you will find: "If a range or cell reference argument contains text, logical values, or empty cells, those values are ignored; however, cells with the value zero are included."

So you have to do nothing special because what you want is simply the default.


2016-05-23 22:56:09

Sharyn Kingston

Can you please tell me how to do an average that includes zero values, but still excludes cells with no value?


2016-05-18 08:45:52

Karen

Thanks!


2016-05-04 05:31:33

Michael (Micky) Avidan

@SAKILARANI,
The AVERAGE Function discards empty cells - so there is no problme for the manager to leave them empty.
Take a look at the picture.
(see Figure 1 below)
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
ISRAEL

Figure 1. 


2016-05-04 01:16:29

SAKILARANI

if column I is an average of the week. If the manager didn't fill out a cell, don't allow that to average in. Just do an average of what was reported.how a pplied the formula


2016-02-25 01:28:17

veeranjaneyulu

=IF(Mapping!R6="",0,AVERAGE(D32:D46))


2015-10-12 13:07:26

Gino

Averaging a non-contiguous range:
http://excelribbon.tips.net/T007845_Averaging_a_Non-Contiguous_Range.html


2015-10-12 12:47:28

Gino

I have a similar situation as Todd


2015-09-17 18:00:57

Todd

seems all the examples show the cells to be averaged in range are in a continuous row. I need to do this function where I need the average of items in about every 3rd cell of a row, and not the whole row. the range includes all cells correct, am I looking at an array??


2015-08-29 10:06:42

shahab

Thanks a lot.


2015-07-23 07:13:58

Michael (Micky) Avidan

@Ben,
In your example it should read:

=AVERAGEIF(A1:A50,"<>0",A1:A50)

Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2015-07-23 07:12:45

Michael (Micky) Avidan

@Ben,
This tip was intended for 2003 and eralier versions users.
However, starting with Excel 2007 - the following formula will achieve the same task without the need for an ampersand.
By the way - the following formula takes into calculation also negative values, therefor I used: "<>0".

=AVERAGEIF(A1:A11,"<>0",A1:A11)

Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2015-07-22 10:33:03

Ben

I had to make a slight change to get it to work for me (Excel 2013). I wanted it documented in case others have a similar problem:

=AVERAGEIFS(A1:A50,A1:A50,">0",A1:A50,"<>""")

is changed to

=AVERAGEIFS(A1:A50,A1:A50,">0",A1:A50,"<>"&"")

Notice the ampersand in the fourth to last character.


2015-04-12 04:19:13

Kate

Really struggling with a Average Function..

I have a range of cells (M9:M18)that have one of three quantities: 100, 50, 0.

These quantities are filled in based on the formula used in the cell to the left of them.

I need to use a formula to come up with an average for these cells and have had no luck with all of the threads I've tried.

Help!


2015-03-01 10:20:36

alec macleod

I want to average monetary values on different sheets with in the same work book that do not include zero


2015-02-05 12:47:06

Cathy

I am wondering how to average a range of cells that include the SUM formula for a line of numbers, but eliminate the cells that do not have a calculation to the sum formula. There may be a '0' input in one of the cells, so I can't just eliminate 0. Is there a way to eliminate the cells that only have the formula without the actual calculation??


2014-12-23 06:40:29

Gary

Hi,

Great tips!

The current AverageIf forumla works well for me. But the problem is it's counting all the Zero's in my data. Are you able to provide guidance on how i add into this formula the exclusion of Zero's?

=AVERAGEIF('YTD PPV - 410'!$A:$A,'Aus - YTD @ Standard'!$B$54&'Aus - YTD @ Standard'!B55,'YTD PPV - 410'!$P:$P)

Many thanks


2014-11-24 14:20:45

Brian

The first formula given:

=AVERAGEIF(A1:A50,">0")

does not do what Veronica wants since there may be negative values in the range. She should instead use:

=AVERAGEIF(A1:A50,"<>0")


2014-11-11 02:06:06

Ricardo A. Reyes

this is my first visit in this site and i was looking for formula that meet my demands, with the help of google I found this site. it is very well explained and was very helpful. thanks you so much. keep up the good work. and hope this site last.


2014-10-14 04:27:17

George

Very well explained, thank you !


2013-04-28 01:14:24

Gaëtane

Thank you, well explained !


2013-04-24 16:29:19

Jamie

First tutorial I found that actually works, went through about 3-4 others.

Thanks,J


2013-03-06 16:55:17

André Terra

Thanks! First hit on google for "average excluding ifs" ;)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing