Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Dropping '0' values out of averages 5

Status
Not open for further replies.

AGlazer

Programmer
Sep 15, 2002
38
US
Hi, everyone.

Quick question. I have a range of values

5
2
0
8
0
2
3

I want to take the average of the non-zero values (i.e., average should be 4, not 2.85. Any ideas?

Thanks,

Aaron


 
Aaron,

I just created a simply example using the following formula and it works fine.

=DSUM(data,1,crit)/DCOUNTA(data,1,crit)

If you're not familiar with database functions, I can email you the file if you like.

Or, here's a quick set of steps...

1) Enter a field name at the top of your column of numbers (you can color it white if you don't want it to show).

2) On a separate sheet, enter the same field name in a cell. In the next cell below the field name, enter: >0

3) Assign a range name (e.g. &quot;crit&quot;) to the criteria. a) Highlight the two cells, b) Hold down <Ctrl> and hit <F3>, c) Type the name, d) Hit <Enter>.

4) Assign a range name to the field of numbers. The top row of this range needs to be the row containing the field name. The bottom row can extend beyond the last row containing number - i.e. you can leave room for numbers to be added later.

5) Enter the formula. You can copy it from below...
=DSUM(data,1,crit)/DCOUNTA(data,1,crit)

Hope this helps. Please advise as to how it fits.

P.S. Once you get used to using Excel's database functions, you'll discover a &quot;whole new world&quot; of &quot;RAW POWER&quot;. For example, you can extract data - selectively -from a database/list to a separate sheet - to generate reports, based on the same &quot;criteria concept&quot;. You only need to modify the criteria to extract the precise data you require.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Assuming your data starts in A! your bormula would be:

=SUM(A1:A7)/COUNTIF(A1:A7,&quot;<>0&quot;)

or

=SUM(Your_Range)/COUNTIF(Your_Range,&quot;<>0&quot;)



Mike
 
Aaron,

Mike's suggestion is a good alternative - for situations such as this where the &quot;criteria&quot; is not complex.

A limitation, though, is that you cannot have Mike's type of formula extend to empty rows - at least at is. You would need to change it to &quot;>0&quot; from &quot;<>0&quot;, as follows...

=SUM(Your_Range)/COUNTIF(Your_Range,&quot;>0&quot;)

Mike's use of &quot;<>0&quot;, however is the proper criteria to use for the database function - if there will potentially be negative numbers. The use of &quot;<>0&quot; will NOT adversely affect the use of the database function.

Hope this helps.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Dale and Mike,

Thanks to both of you for your (quite) thorough answers -- very helpful and much appreciated.

Aaron
 
Just another option:-

=AVERAGE(IF(Your_Range<>0,Your_Range))

array entered - CTRL+SHIFT+ENTER

Regards
Ken............
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top