Ask LibreOffice - RSS feedhttps://ask.libreoffice.org/en/questions/Questions and answers for LibreOfficeenThu, 10 Aug 2017 14:25:34 +0200possible bug in addition of formula result if result is "" (blank)https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/I have a small spreadsheet that shows this problem and if I can figure out how to attach it or upload it I will.
The problem I'm seeing is this:
I have a formula that generates either a blank or a number. The result of this formula is added to another number. If the formula generates a blank the result of cell+cell is #value, but the result of sum(cell:cell) is correct.
Looks like I can't upload an example SS so here goes a long and tedious explanation.
Please enter the following and you will see the problem:
Cell A1 1
Cell A3 1
Cell A4 blank (i.e. nothing in this cell)
Cell A5 3
Cell A6 =A3+A4+A5
Cell B3 1
Cell B4 =if(A1=1,"",2)
Cell B5 3
Cell B6 =B3+B4+B5
Cell C3 1
Cell C4 =if(A1=1,"",2)
Cell C5 3
Cell C6 =sum(C3:C5)
If you get the same result I got then you will see the following:
A6 4
B6 #VALUE!
C6 4
This looks like a bug to me. Somehow when the formula evaluates to "", addition fails, though a simple, non-formulaic "" works fine.
I'm hoping someone will either verify the problem and I'll report a bug, or explain to me what I'm doing wrong.Tue, 08 Aug 2017 05:10:39 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/Answer by JohnSUN for <p>I have a small spreadsheet that shows this problem and if I can figure out how to attach it or upload it I will.</p>
<p>The problem I'm seeing is this:
I have a formula that generates either a blank or a number. The result of this formula is added to another number. If the formula generates a blank the result of cell+cell is #value, but the result of sum(cell:cell) is correct.</p>
<p>Looks like I can't upload an example SS so here goes a long and tedious explanation.
Please enter the following and you will see the problem:</p>
<p>Cell A1 1 <br>
Cell A3 1 <br>
Cell A4 blank (i.e. nothing in this cell) <br>
Cell A5 3 <br>
Cell A6 =A3+A4+A5 </p>
<p>Cell B3 1 <br>
Cell B4 =if(A1=1,"",2) <br>
Cell B5 3 <br>
Cell B6 =B3+B4+B5 </p>
<p>Cell C3 1 <br>
Cell C4 =if(A1=1,"",2) <br>
Cell C5 3 <br>
Cell C6 =sum(C3:C5) </p>
<p>If you get the same result I got then you will see the following: <br>
A6 4 <br>
B6 #VALUE! <br>
C6 4 </p>
<p>This looks like a bug to me. Somehow when the formula evaluates to "", addition fails, though a simple, non-formulaic "" works fine.</p>
<p>I'm hoping someone will either verify the problem and I'll report a bug, or explain to me what I'm doing wrong.</p>
https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=120378#post-id-120378You can fix it if use in cell B4 formula
=IF(A1=1;;2)
and format result "without zero" (format code **0;0;;@** )
Or use in cell B6 a formula
=B3+N(B4)+B5
I mean that cells with results of formulas additionaly need function N() which will convert empty string to zero
**Update** In addition, you can simply change the behavior of the program in this part.
![Empty string or zero](/upfiles/1502299120161261.png)Tue, 08 Aug 2017 09:18:36 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=120378#post-id-120378Answer by paravantis for <p>I have a small spreadsheet that shows this problem and if I can figure out how to attach it or upload it I will.</p>
<p>The problem I'm seeing is this:
I have a formula that generates either a blank or a number. The result of this formula is added to another number. If the formula generates a blank the result of cell+cell is #value, but the result of sum(cell:cell) is correct.</p>
<p>Looks like I can't upload an example SS so here goes a long and tedious explanation.
Please enter the following and you will see the problem:</p>
<p>Cell A1 1 <br>
Cell A3 1 <br>
Cell A4 blank (i.e. nothing in this cell) <br>
Cell A5 3 <br>
Cell A6 =A3+A4+A5 </p>
<p>Cell B3 1 <br>
Cell B4 =if(A1=1,"",2) <br>
Cell B5 3 <br>
Cell B6 =B3+B4+B5 </p>
<p>Cell C3 1 <br>
Cell C4 =if(A1=1,"",2) <br>
Cell C5 3 <br>
Cell C6 =sum(C3:C5) </p>
<p>If you get the same result I got then you will see the following: <br>
A6 4 <br>
B6 #VALUE! <br>
C6 4 </p>
<p>This looks like a bug to me. Somehow when the formula evaluates to "", addition fails, though a simple, non-formulaic "" works fine.</p>
<p>I'm hoping someone will either verify the problem and I'll report a bug, or explain to me what I'm doing wrong.</p>
https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=120380#post-id-120380I would like to enhance @JohnSUN's on-the-spot explanation, by adding that the behavior @dottore describes as buggy is identical to what happens when such a spreadsheet is opened in **Excel 2016**: the B6 cell gives a #VALUE unless the formulas are corrected as described by @JohnSUN.
It certainly does not look like a bug to me.
BTW, good post, it was a great opportunity to learn something new in spreadsheet functions!Tue, 08 Aug 2017 09:40:38 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=120380#post-id-120380Comment by JohnSUN for <p>I would like to enhance <a href="/en/users/1270/johnsun/">@JohnSUN</a>'s on-the-spot explanation, by adding that the behavior <a href="/en/users/36377/dottore/">@dottore</a> describes as buggy is identical to what happens when such a spreadsheet is opened in <strong>Excel 2016</strong>: the B6 cell gives a #VALUE unless the formulas are corrected as described by <a href="/en/users/1270/johnsun/">@JohnSUN</a>.</p>
<p>It certainly does not look like a bug to me.</p>
<p>BTW, good post, it was a great opportunity to learn something new in spreadsheet functions!</p>
https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?comment=120394#post-id-120394Yes, you're right. Excel 2003 and Excel 2010 work the same way.Tue, 08 Aug 2017 10:51:59 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?comment=120394#post-id-120394Answer by Regina for <p>I have a small spreadsheet that shows this problem and if I can figure out how to attach it or upload it I will.</p>
<p>The problem I'm seeing is this:
I have a formula that generates either a blank or a number. The result of this formula is added to another number. If the formula generates a blank the result of cell+cell is #value, but the result of sum(cell:cell) is correct.</p>
<p>Looks like I can't upload an example SS so here goes a long and tedious explanation.
Please enter the following and you will see the problem:</p>
<p>Cell A1 1 <br>
Cell A3 1 <br>
Cell A4 blank (i.e. nothing in this cell) <br>
Cell A5 3 <br>
Cell A6 =A3+A4+A5 </p>
<p>Cell B3 1 <br>
Cell B4 =if(A1=1,"",2) <br>
Cell B5 3 <br>
Cell B6 =B3+B4+B5 </p>
<p>Cell C3 1 <br>
Cell C4 =if(A1=1,"",2) <br>
Cell C5 3 <br>
Cell C6 =sum(C3:C5) </p>
<p>If you get the same result I got then you will see the following: <br>
A6 4 <br>
B6 #VALUE! <br>
C6 4 </p>
<p>This looks like a bug to me. Somehow when the formula evaluates to "", addition fails, though a simple, non-formulaic "" works fine.</p>
<p>I'm hoping someone will either verify the problem and I'll report a bug, or explain to me what I'm doing wrong.</p>
https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=120516#post-id-120516The difference between operator + and the sum() function is, that the operator + expects a single number and the function sum() expects a number sequence. And a conversion to number sequence is handled different in the specification.
Find the specification for formulas in http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.html.
The section 6.3.5 describes, what to do, if the operand does not has the expected type. For text -> number the specification says, that it is "implementation-defined". LibreOffice tries to do the conversion similar to Excel as far as possible. That gives some non obvious results and opening the document with a different application might result in different values. Therefore I'm not happy with the decision to not throw an error in all conversion cases. For example in a German local the text "2.345" converts to the integer number 2345, the text "2.34" results in an error and the text "2,345" results in a decimal number, as the comma is the decimal separator and dot is the thousand-separator in Germany. The conversion is different in an EN-US local. For all this a simple rule is, to **never** use text with simple arithmetic operators.
The section 6.3.7 describes, how to convert a reference (B3:B5 in your example) to a number sequence. And in this section you find "Thus, Empty cells and Text that could be converted into a value is not included in a number sequence." So the sum() functions gets only cells, which result in a real number. So here the conversion is unambiguous.
Tue, 08 Aug 2017 19:17:30 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=120516#post-id-120516Comment by dottore for <p>The difference between operator + and the sum() function is, that the operator + expects a single number and the function sum() expects a number sequence. And a conversion to number sequence is handled different in the specification.</p>
<p>Find the specification for formulas in <a href="http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.html">http://docs.oasis-open.org/office/v1....</a>.</p>
<p>The section 6.3.5 describes, what to do, if the operand does not has the expected type. For text -> number the specification says, that it is "implementation-defined". LibreOffice tries to do the conversion similar to Excel as far as possible. That gives some non obvious results and opening the document with a different application might result in different values. Therefore I'm not happy with the decision to not throw an error in all conversion cases. For example in a German local the text "2.345" converts to the integer number 2345, the text "2.34" results in an error and the text "2,345" results in a decimal number, as the comma is the decimal separator and dot is the thousand-separator in Germany. The conversion is different in an EN-US local. For all this a simple rule is, to <strong>never</strong> use text with simple arithmetic operators.</p>
<p>The section 6.3.7 describes, how to convert a reference (B3:B5 in your example) to a number sequence. And in this section you find "Thus, Empty cells and Text that could be converted into a value is not included in a number sequence." So the sum() functions gets only cells, which result in a real number. So here the conversion is unambiguous.</p>
https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?comment=120903#post-id-120903you hit on the exact problem. "conversion to number sequence is handled different..." Why doesn't + also convert the cell contents to a number? + should go thru the exact same steps that SUM goes thru, just on individual cells vs arrays. That would guarantee that + and SUM always give the exact same results. I think this is a problem in the specification. JMHO, of course.Wed, 09 Aug 2017 18:47:07 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?comment=120903#post-id-120903Answer by dottore for <p>I have a small spreadsheet that shows this problem and if I can figure out how to attach it or upload it I will.</p>
<p>The problem I'm seeing is this:
I have a formula that generates either a blank or a number. The result of this formula is added to another number. If the formula generates a blank the result of cell+cell is #value, but the result of sum(cell:cell) is correct.</p>
<p>Looks like I can't upload an example SS so here goes a long and tedious explanation.
Please enter the following and you will see the problem:</p>
<p>Cell A1 1 <br>
Cell A3 1 <br>
Cell A4 blank (i.e. nothing in this cell) <br>
Cell A5 3 <br>
Cell A6 =A3+A4+A5 </p>
<p>Cell B3 1 <br>
Cell B4 =if(A1=1,"",2) <br>
Cell B5 3 <br>
Cell B6 =B3+B4+B5 </p>
<p>Cell C3 1 <br>
Cell C4 =if(A1=1,"",2) <br>
Cell C5 3 <br>
Cell C6 =sum(C3:C5) </p>
<p>If you get the same result I got then you will see the following: <br>
A6 4 <br>
B6 #VALUE! <br>
C6 4 </p>
<p>This looks like a bug to me. Somehow when the formula evaluates to "", addition fails, though a simple, non-formulaic "" works fine.</p>
<p>I'm hoping someone will either verify the problem and I'll report a bug, or explain to me what I'm doing wrong.</p>
https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=120902#post-id-120902I appreciate the effort you all have put into this. Seems like a "feature" vs "a bug", though that is poor consolation to a user.
From a user's point of view I note the following:
1) this works in OpenOffice calc, at least from 3.0 to 4.3. I.e. #VALUE! is not displayed, you get 4 in all cases. I ran into this problem when I tried to use a SS that had been developed on OO calc.
2) The laws of mathematics define SUM and + as identical mathematical operations. That they should give the same answer in all cases is a mathematical law that should supersede any software specifications. I would argue that the specification is the problem, and that either all cases of the example should fail or none.
3) I don't care what Excel does. As a user I want 3+""+4 to equal 7, no matter how the "" got put into a cell.
4) Regarding what can be done to convert the equation result to a number type, why does the "" that results from the if statement need conversion when the literal blank does not? Again, I am asking from the user's point of view, not the programmers. I understand that a null string may be different from an empty cell from a programmer's point of view, but what the user sees in the cell looks exactly the same.
5) The brilliance of Excel and all subsequent spreadsheets is that it made data manipulation easy for the non-programmer user (and programmers for that matter). It relieved the user of the need to understand the workings of the computer, to understand data types, for example. So make it easy.
Anyway, this isn't very important in the great scheme of things. Decide whatever you want. I have a good work around. I can enter =SUM(B3:B4) instead of =B3+B4 and I get a sensible result. I've been programming since 1964 and I expect bugs and features and am pretty good at figuring ways around them. I think most people who come up against this problem will quickly find a work around (took me 5 minutes, way less time than any of us have spent on this thread).
Again, thanks for the effort everyone put in.
Over and out.
Wed, 09 Aug 2017 18:40:24 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=120902#post-id-120902Comment by JohnSUN for <p>I appreciate the effort you all have put into this. Seems like a "feature" vs "a bug", though that is poor consolation to a user.</p>
<p>From a user's point of view I note the following:</p>
<p>1) this works in OpenOffice calc, at least from 3.0 to 4.3. I.e. #VALUE! is not displayed, you get 4 in all cases. I ran into this problem when I tried to use a SS that had been developed on OO calc.</p>
<p>2) The laws of mathematics define SUM and + as identical mathematical operations. That they should give the same answer in all cases is a mathematical law that should supersede any software specifications. I would argue that the specification is the problem, and that either all cases of the example should fail or none.</p>
<p>3) I don't care what Excel does. As a user I want 3+""+4 to equal 7, no matter how the "" got put into a cell.</p>
<p>4) Regarding what can be done to convert the equation result to a number type, why does the "" that results from the if statement need conversion when the literal blank does not? Again, I am asking from the user's point of view, not the programmers. I understand that a null string may be different from an empty cell from a programmer's point of view, but what the user sees in the cell looks exactly the same.</p>
<p>5) The brilliance of Excel and all subsequent spreadsheets is that it made data manipulation easy for the non-programmer user (and programmers for that matter). It relieved the user of the need to understand the workings of the computer, to understand data types, for example. So make it easy.</p>
<p>Anyway, this isn't very important in the great scheme of things. Decide whatever you want. I have a good work around. I can enter =SUM(B3:B4) instead of =B3+B4 and I get a sensible result. I've been programming since 1964 and I expect bugs and features and am pretty good at figuring ways around them. I think most people who come up against this problem will quickly find a work around (took me 5 minutes, way less time than any of us have spent on this thread).</p>
<p>Again, thanks for the effort everyone put in.</p>
<p>Over and out.</p>
https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?comment=120904#post-id-120904OK, you are completely right. In each paragraph. And I'm grateful to you for this text - he forced me to look again at the corresponding settings of the program. Unfortunately, here I can not add a picture, I will add it to my answer.Wed, 09 Aug 2017 19:16:52 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?comment=120904#post-id-120904Answer by Lupp for <p>I have a small spreadsheet that shows this problem and if I can figure out how to attach it or upload it I will.</p>
<p>The problem I'm seeing is this:
I have a formula that generates either a blank or a number. The result of this formula is added to another number. If the formula generates a blank the result of cell+cell is #value, but the result of sum(cell:cell) is correct.</p>
<p>Looks like I can't upload an example SS so here goes a long and tedious explanation.
Please enter the following and you will see the problem:</p>
<p>Cell A1 1 <br>
Cell A3 1 <br>
Cell A4 blank (i.e. nothing in this cell) <br>
Cell A5 3 <br>
Cell A6 =A3+A4+A5 </p>
<p>Cell B3 1 <br>
Cell B4 =if(A1=1,"",2) <br>
Cell B5 3 <br>
Cell B6 =B3+B4+B5 </p>
<p>Cell C3 1 <br>
Cell C4 =if(A1=1,"",2) <br>
Cell C5 3 <br>
Cell C6 =sum(C3:C5) </p>
<p>If you get the same result I got then you will see the following: <br>
A6 4 <br>
B6 #VALUE! <br>
C6 4 </p>
<p>This looks like a bug to me. Somehow when the formula evaluates to "", addition fails, though a simple, non-formulaic "" works fine.</p>
<p>I'm hoping someone will either verify the problem and I'll report a bug, or explain to me what I'm doing wrong.</p>
https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=121019#post-id-121019**No bug!** See answer by @Regina and explanations in the attached **[demo](/upfiles/15023575302965893.ods)**.
-1- **Use `SUM(B3;B4;B5)` or `SUM(B3:B5)` instead of `B3+B4+B5` to get what you want in conformance with the specifications. `SUM()` will ignore *any* text, but this should not spoil anything.**
-2- Do **not** rely on obscure settings. Be explicit! Otherwise you endanger even the rudiments of clarity created by odf specifications.
The attached demo also contains an addendum concerning the conflicts and misunderstandings coming up again and again in this context.Thu, 10 Aug 2017 11:30:34 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?answer=121019#post-id-121019Comment by paravantis for <p><strong>No bug!</strong> See answer by <a href="/en/users/7415/regina/">@Regina</a> and explanations in the attached <strong><a href="/upfiles/15023575302965893.ods">demo</a></strong>. </p>
<p>-1- <strong>Use <code>SUM(B3;B4;B5)</code> or <code>SUM(B3:B5)</code> instead of <code>B3+B4+B5</code> to get what you want in conformance with the specifications. <code>SUM()</code> will ignore <em>any</em> text, but this should not spoil anything.</strong> </p>
<p>-2- Do <strong>not</strong> rely on obscure settings. Be explicit! Otherwise you endanger even the rudiments of clarity created by odf specifications. </p>
<p>The attached demo also contains an addendum concerning the conflicts and misunderstandings coming up again and again in this context.</p>
https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?comment=121091#post-id-121091Good post, thank you!Thu, 10 Aug 2017 14:25:34 +0200https://ask.libreoffice.org/en/question/120322/possible-bug-in-addition-of-formula-result-if-result-is-blank/?comment=121091#post-id-121091