# I need to calculate the averages of a range without counting

#### afs24

##### Board Regular
I'm trying to calculate the average of a range of cells with the numbers (ex: 200,300,0,0). The answer should be 250 not 125 when dividing by 4. Zero shouldn't count because there's always a number for in spreadsheet. I'm adding up the sum of the four numbers and dividing it by the count but it's counting the zero? HELP????

### Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Let A2:A10 house the numbers of interest.

=SUM(A2:A10)/MAX(1,COUNT(A2:A10)-COUNTIF(A2:A10,0))

will produce the desired average of non-zero numbers.

With your numbers in A1 to A4, in A5

=SUMIF(A1:A4,">0")/4

gives 125

In the answer supplied by Vog(tm), if one of the numbers in the data base is less than 0 the answer would be different than in the answer supplied by Aladin. Also if the quantify of data is different than 4, you would have to modify that to the new total data counts .....Aladin's answer seem to account for both issue within the formular.

pll

Good point plettieri.

=SUMIF(A1:A4,"<>0")/4

works correctly with negative numbers.

[...]

=SUMIF(A1:A4,"<>0")/4

works correctly with negative numbers.

The question afs24 posed is:

[/quote]I'm trying to calculate the average of a range of cells with the numbers (ex: 200,300,0,0). The answer should be 250 not 125 when dividing by 4. Zero shouldn't count...[/b]

The SUMIF formula doesn't satisfy the requirements: It would just produce 125 as average when applied to: {200,300,0,0} entered in A1:A4, while

=SUM(A1:A4)/MAX(1,COUNT(A1:A4)-COUNTIF(A1:A4,0))

will produce the desired average of 250.

This formula "works correctly with negative numbers" too, as it should:

Enter {-200,300,0,0} in A1:A4...

The result should be 50 by afs24's specs.

Thank you. I must learn to read and think before posting (twice!).

P.S. this does work

=SUMIF(A1:A4,"<>0")/COUNTIF(A1:A4,"<>0")
This message was edited by VoG™ on 2002-09-29 08:28

Replies
0
Views
174
Replies
8
Views
282
Replies
0
Views
111
Replies
2
Views
400
Replies
0
Views
450

1,207,089
Messages
6,076,517
Members
446,211
Latest member
b306750

### We've detected that you are using an adblocker.

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?

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.
Go back