SUM formula that will ignore #N/A's

Discuss the spreadsheet application
Post Reply
BillLillard
Posts: 3
Joined: Wed Nov 22, 2017 1:42 am

SUM formula that will ignore #N/A's

Post by BillLillard »

Hello, I was looking for some help and Google has been a dead end. I just created a VLOOKUP table that has multiple output cells that I want to sum up. The problem is that the number of inputs will vary and I will have several #N/A returns. That's fine, as there's no value needed for those, but now I want to sum up the results, and summing up a range that includes #N/A's just spits out... an #N/A. Is there a SUM formula that will ignore the #N/A's in the range?

After all the trouble of learning how to set up the rest of this table, I can't believe I'm hung up on a simple SUM...

I found this: =SUMIF(I2:I25;"<>#N/A")
But it's not working.

Thanks,
Bill
OpenOffice 4.1.2 on Windows 10
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: SUM formula that will ignore #N/A's

Post by RusselB »

While I haven't come up with a simple solution, I can explain why the formula you posted isn't working.
The formula you posted is looking for the string #N/A in the cells.
The #N/A that you see is actually an error report, not the string #N/A (which your formula requires). It can be generated using =NA() and detected using =ISNA(<cell_reference>)
See the help file for more details.
I don't know how many or how complicated your formulas are, but one option is to check if the formula is going to generate a #N/A (using the ISNA function), and then force it to return something that isn't an error (such as your #N/A string, which in turn would make your suggested formula work).
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
robleyd
Moderator
Posts: 5082
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: SUM formula that will ignore #N/A's

Post by robleyd »

Use the function ISNA() in conjunction with your VLOOKUP() so your lookup returns a blank rather than #N/A

If (vlookup returns N/A; "";result of valid vlookup)
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
User avatar
Lupp
Volunteer
Posts: 3549
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: SUM formula that will ignore #N/A's

Post by Lupp »

Any expression getting an NA() operand or parameter will pass the NA() to its result if not explicitly specified to do otherwise.
The relevant function specified in this exceptional way is the logical function ISNA(AnyTypeParmeter). You can therefore use

Code: Select all

=SUM(IF(ISNA(A1:A4);"";A1:A4))
to get the sum for the range A1:A4 ignoring cells returning the NA() error. Text, also the empty text, is ignored by SUM() as you will know.

You can also use formulas like

Code: Select all

=IF(ISERROR(expression)then"";expression) or
=IF(ISNA(expression)then"";expression)
in every cell suspected to get an NA() result sometimes (by VLOOKUP() e.g.) if you accept the inefficiency of evaluating the same expression often a second time.

Since V4.0 (released 2013, week 6) LibreOffice Calc has implemented the functions IFERROR() and IFNA() usable like in the example

Code: Select all

=IFNA(expression;"")
which will return the empty string if expression evaluates to NA() and the calculated result (value or error code) otherwise. AOO did not yet implement these useful functions specifiued in OpenFormula.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
BillLillard
Posts: 3
Joined: Wed Nov 22, 2017 1:42 am

Re: SUM formula that will ignore #N/A's

Post by BillLillard »

Ok. Well.

Sorry, I'm not well versed in this software. I do understand that #N/A is something that one would normally want to know about and fix, but that with VLOOKUP it can be a normal part of the results. In my case, they're fine coming out of the initial calculations. All I have left is a 24 cell range that I want to sum, and these #N/A's are killing the result.

If I was to use a formula in conjuction with my VLOOKUP formulas, I wouldn't even know where to put them. I'm actually shocked that there's no way to just ignore an error. Or if there is, like with ISERROR or ISNA, I guess I just don't know how to implement it. Basically my formula would/should be =SUM(I2:I25). Very simple. Can I just add something to that to ignore the #N/A's that are in the field?

Sorry, I'm very new to this, but I appreciate the help.
OpenOffice 4.1.2 on Windows 10
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: SUM formula that will ignore #N/A's

Post by RusselB »

See the first formula supplied by Lupp
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
Lupp
Volunteer
Posts: 3549
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: SUM formula that will ignore #N/A's

Post by Lupp »

I missed to make clear that that formula must be entered for array-evaluation with Ctrl+Shift+Enter. Adapted to the range given by the OQ it will then be shown for the cell as

Code: Select all

{=SUM(IF(ISNA(I2:I25);"";I2:I25))}
(The curly brackets must not be entered!)
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
robleyd
Moderator
Posts: 5082
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: SUM formula that will ignore #N/A's

Post by robleyd »

To make it fully clear, enter

Code: Select all

=SUM(IF(ISNA(I2:I25);"";I2:I25))
without the curlies in the formula bar and then press Ctrl+Shift+Enter. Calc will add the curly brackets.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Post Reply