Creating average over DIV/0 inclusive range

Sayth

Board Regular
Joined
Jun 4, 2010
Messages
213
HI

If I have a simple range G4:G17 and I want to calculate an average of the range you would use Average(G4:G17). However if the range sometimes contains DIV/0 in a field how would I calculate the average of the range.

I thought that if I said to sumif the range if not div/0 and divide it by the countif not div/0 I would get the range average. But I must be writing it wrong its not working.

My Code:
Code:
=(SUMIF((G4:G17,"<>#DIV/0!")))/(COUNTIF(IF(G4:G17,"<>#DIV/0!")))
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
<TABLE style="WIDTH: 305pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=406><COLGROUP><COL style="WIDTH: 305pt; mso-width-source: userset; mso-width-alt: 7424" width=406><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: #eaf1dd; WIDTH: 305pt; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl63 height=20 width=406>=AVERAGEIF(L11:L16,"<>#DIV/0!")</TD></TR></TBODY></TABLE>
 
Upvote 0
HI

If I have a simple range G4:G17 and I want to calculate an average of the range you would use Average(G4:G17). However if the range sometimes contains DIV/0 in a field how would I calculate the average of the range.

I thought that if I said to sumif the range if not div/0 and divide it by the countif not div/0 I would get the range average. But I must be writing it wrong its not working.

My Code:
Code:
=(SUMIF((G4:G17,"<>#DIV/0!")))/(COUNTIF(IF(G4:G17,"<>#DIV/0!")))

These two functions can be made to work...

=SUMIF(G4:G17,"<"&9.99E+307)/MAX(1,COUNTIF(G4:G17,"<"&9.99E+307))

If G4:G17 is guaranteed to solely house numeric values >= 0, then:

=SUMIF(G4:G17,">0")/MAX(1,COUNTIF(G4:G17,">=0"))
 
Upvote 0
HI

If I have a simple range G4:G17 and I want to calculate an average of the range you would use Average(G4:G17). However if the range sometimes contains DIV/0 in a field how would I calculate the average of the range.

I thought that if I said to sumif the range if not div/0 and divide it by the countif not div/0 I would get the range average. But I must be writing it wrong its not working.

My Code:
Code:
=(SUMIF((G4:G17,"<>#DIV/0!")))/(COUNTIF(IF(G4:G17,"<>#DIV/0!")))
In Excel 2007 or later...

Book1
G
488
539
682
7#DIV/0!
852
949
1015
11#DIV/0!
1223
1352
1486
1525
1682
1752
Sheet1

=AVERAGEIF(G4:G17,"<1E100")
 
Upvote 0

Forum statistics

Threads
1,224,508
Messages
6,179,188
Members
452,893
Latest member
denay

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?

Disable AdBlock

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
Back
Top