Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Function to replace division by zero error cells with blank cells when calculating a numeric average

Hi everyone,


I have a five sheet spreadsheet that uses data from four sheets to calculate numeric averages in the fifth. The problem is that there is not always data in all four sheets which produces a division by zero error in the averages sheet. Is there a function or setting in Numbers 2.3 (not yet ready to upgrade to Numbers 3) that will allow these division by zero cells to be replaced by blank cells.


I have tried using statements of the form =AVERAGE(IFERROR(Sheet 1::Table 1:: B4,""),IFERROR(Sheet 2:: Table 1:: B4,""),Sheet 3:: Table 1:: B4,""), Sheet 4:: Table 1:: B4,"")). however instead of a division by zero error this produces an error telling me "the function AVERAGE expects that a number, date or duration but found "." ". It looks as though I will have to make about 400 changes to my sheet as these errors are in this and approximately 100 other cells! 😟


I am hoping that there is some way if possible of correcting these errors without having to manually edit each cell individually.


Thanks,


Hugh

OS X Mavericks (10.9.1)

Posted on Feb 7, 2014 5:27 AM

Reply
Question marked as Best reply

Posted on Feb 7, 2014 5:43 AM

To be more clear on your problem, you want to average cells that may contain errors?


This seems to work:


=AVERAGEIF(UNION.RANGES(0,Sheet 1::Table 1::B4,Sheet 2::Table 1::B4,Sheet 3::Table 1::B4,Sheet 4::Table 1::B4),"<>")

20 replies

Feb 7, 2014 6:45 AM in response to Badunit

Thanks Badunit,


To clarify, my problem is that one (or more) of the sheets may contain empty cells. This then creates a division by zero error because each empty cell is divided by the sum of the empty cells (=0). This error then appears in both the original sheet and the averages sheet. I am trying to tackle the problem from the averages sheet as I would have four times as much work to error protect the other sheets.


I tried replacing my =AVERAGE(IFERROR... statement displaying the "AVERAGE expects a number... " message in my Averages sheet with the function you gave me:


=AVERAGEIF(UNION.RANGES(0,Sheet 1::Table 1::B4,Sheet 2::Table 1::B4,Sheet 3::Table 1::B4,Sheet 4::Table 1::B4),"<>")

but it doesn't seem to work as I am now getting a " "UNION.RANGES" isn't a valid function name" " error message.

Feb 7, 2014 6:59 AM in response to hughmacfarlane

Hugh,


I think Badunit may have missed that you are still on version 2.3, which doesn't have that function.


I confess that I'm not as good at visualizing your situation as I probably should be, but if you could post a screen shot or two it might be helpful. There are a ways to avoid creating errors by checking for content before executing the function, rather than letting the error happen and then trapping it.


Jerry

Feb 7, 2014 7:14 AM in response to hughmacfarlane

The error message from your formula implies that one of the IFERROR functions is finding an error and replacing it with a null string, as you asked it to do. If the problem was that all the cells being averaged were blank or zero, you would get a divide by zero error instead. You could put an IFERROR around the whole formula to trap that error.


UNION.RANGES is a valid function in Numbers 3 but not prior versions. I somehow totally skipped over the part where you said 2.3


I originally wrote some more here but I removed it because I am confused. You said the cells to be averaged may be empty. But you also seem to be saying the cells might have errors in them. An error is not the same as empty. A correct answer requires a full description of the problem

Feb 7, 2014 8:17 AM in response to Jerrold Green1

Jerrold,


Thanks for getting back to me. Below is a screenshot of one of the tables that I have in each of the subsidiary sheets that contribute to my Averages main sheet. User uploaded file

The highlighted cell is one of those referenced in the Averages sheet when a data set is missing and which I am trying to get Numbers to treat as if it were blank so and thus calculate the average of the remaining sets. I used IFERROR statements in the Averages sheet not realising it was incompatible with the AVERAGE function.

Feb 7, 2014 8:54 AM in response to Badunit

Badunit,


The null string was an unsuccessful attempt to trap the division by zero error. IFERROR has to go inside AVERAGE otherwise I would get blanks in the AVERAGES mainsheet.


I have managed to google something in an EXCEL forum that seems to work but will take ages to replace the 400 null strings with references to an empty cell. I am hoping that someone can come up with something that won't take as long,


User uploaded file


Hugh

Feb 7, 2014 10:48 AM in response to hughmacfarlane

Hugh,


You may want to consider an intermediate sheet to handle the errors and then pass the result on to the main sheet.


In the following mockup, I've created a small interposing table the consists of a list of sources in column A and the result from each table. In the example, I perform some operation on those intermediate results, to be passed on to the main table. This may not be a good example, and since I don't know the overall goal of your project it's just a surrogate. (In real life we probably wouldn't be interested in finding the average of averages.)


User uploaded file

The expression in Summary::B2 is:


=IFERROR(INDIRECT(A&"::B4"), "SourceError")


Regards,


Jerry

Feb 7, 2014 11:10 AM in response to hughmacfarlane

Hugh,


You have 400 unique formulas, not a few that can be copy/pasted or filled to the other cells? I do not know why your spreadsheet is that way but maybe you should consider redesigning the structure of it so you can copy/paste formulas or maybe you can develop a formula that can be copy/pasted to other cells. Typical spreadsheets have few unique formulas. There may be thousands of formulas in total but only a few unique ones. The rest of the cells are populated by copy/paste or fill.

Feb 7, 2014 2:02 PM in response to Wayne Contello

Wayne,


I will keep this in mind as it will be helpful in future but I can't see how I can integrate it right now with what I have at present to calculate the average of four cells located on other sheets when one or more of those cells contains a division by zero. I started with multiple cells of the form " =AVERAGE(Sheet 1::Table1::D3,Sheet 2::Table 1::D3,Sheet 3::Table 1::D3,Sheet 4::Table 1::D3) but soon discovered that if the data for one of the sheets was missing, the Averages sheet went missing too. So I tried enclosing each cell in IFERROR(*,"") which doesn't work. I have discovered that it will work if I replace the null string with a reference to an empty cell which is a lot of work as I removed all my absolute references in order to be able to move the tables around to accomodate modifications to the spreadsheet.


Thanks again,


Hugh

Function to replace division by zero error cells with blank cells when calculating a numeric average

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.