Bug 100620 - Wrong result with COUNTA or COUNT in formula
Summary: Wrong result with COUNTA or COUNT in formula
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.1.4.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-26 15:23 UTC by andis.lazdins
Modified: 2021-07-25 03:24 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Problem using count and counta function (19.58 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-06-26 15:23 UTC, andis.lazdins
Details
The original file saved as a MS Excel 2003 file (11.50 KB, application/x-ole-storage)
2017-04-04 15:07 UTC, Carlos
Details
The original file saved as a MS Excel 2007-2013 file (8.50 KB, application/zip)
2017-04-04 15:10 UTC, Carlos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description andis.lazdins 2016-06-26 15:23:26 UTC
Created attachment 125927 [details]
Problem using count and counta function

The problem appears in many files, where COUNT or COUNTA function is used. When opening attached file in Libreoffice 5.1.4.2, cells C4 to S4 shows Err:522 and the only way to get calculation done is to use another row for COUNT or COUNTA function (like it is done in row 13 in attached file). In previous versions of Libreoffice and Openoffice.org both approaches (row 4 and row 13 worked fine).

Considering that count and counta are basic functions, this might be serious regression. I don't think it is Excel compatibility related "improvement" because Excel understands both approaches.
Comment 1 andis.lazdins 2016-06-26 15:25:13 UTC
Forgot to mention: Ubuntu 14.04, 32 bit
Comment 2 m_a_riosv 2016-06-26 21:21:44 UTC
Hi @andis,

Err:522 as you can see in the status bar means a "circular reference", it happens when a cell is included in the calculation of their formula (directly or indirectly)

There is an option to allow calculate with circular references:
Menu/Tools/Options/LibreOffice calc/Calculate - Iterative references.
that avoid the errors.

Closed as not a bug, please if you are not agree, reopen it.
Comment 3 andis.lazdins 2016-06-26 22:11:53 UTC
Thank you for advice in solving this problem! 

I find mistake in the initial report - it applies to 5.1.4.2!

Iterative references is not really solution, because it is possible to get more compatibility and calculation result related problems in future by activating the Iterative references function.

Formulas in attached file works well in Libreoffice 5.0.x, Openoffice.org 4.1.2 and Microsoft Excel and Iterative references are not activated in Libreoffice 5.0.x and Openoffice.org 4.1.2. Therefore to my understanding, keeping in mind hundreds or thousands of files, which now shows error instead of result in 5.1.x, it is serious regression in basic calc functions.

I reopened the report, because I messed up versions of Libeoffice at the beginning.
Comment 4 m_a_riosv 2016-06-26 22:41:19 UTC
I did my test with:
Win10x64
Version: 5.1.4.2 (x64)
Build ID: f99d75f39f1c57ebdd7ffc5f42867c12031db97a
CPU Threads: 1; OS Version: Windows 6.19; UI Render: GL

The matter it's the same with:
Version: 5.0.6.2 (x64)
Build ID: b3fbfa99158a1030fb79f0ba72b6851afc3c7895-GL
Version: 5.3.0.0.alpha0+
Build ID: 757f221bceb74ccc2af8a9d4de149076280f29fb
CPU Threads: 4; OS Version: Windows 6.19; UI Render: GL; 
TinderBox: Win-x86@39, Branch:master, Time: 2016-06-23_23:54:55

Err:522 it's there, and it is a 'circular reference' error, if 'Iterative references' it's not enable.

The only bug could be if there wasn't circular references, but C4 calls B4, while B4 has COUNTA($B4:$T4) where C4 is part of the range.

So for not a bug, you can ask for help in ask.libreoffice.org or in mailing list http://nabble.documentfoundation.org/Users-f1639498.html
Comment 5 andis.lazdins 2016-06-27 06:28:54 UTC
Thank you for quick response!

This issue really is not a big problem. However, circular reference this time is recognized by mistake. COUNTA calls to number of cells with no relation to values and it is strange change in compare to previous versions and to other office suites. Therefore to me it is regression.
Comment 6 Aron Budea 2016-08-31 02:58:47 UTC
Note this in the help for COUNTA, values matter in the cells:
"If an argument is an array or reference, empty cells within the array or reference are ignored."

I think that makes it clear it's intended behavior, and not a bug, since the circular reference exists because of the definition. What do you think Andis?

The behavior was changed in v4.1.0.4, by the way.
Comment 7 andis.lazdins 2016-08-31 04:41:34 UTC
Hello!

This is manageable, however confusing for those used to Excel or Openoffice.org Scalc. Probably, it is worth to understand, why this "feature" is introduced and may be there is easy way to get rid of it to keep compliance with other spreadsheet applications.
Considering limited resources instead of this bug I would definitely vote for increase of performance of Scalc, which is becoming more and more evident problem with every release.

> 
> I think that makes it clear it's intended behavior, and not a bug, since the
> circular reference exists because of the definition. What do you think Andis?
Comment 8 Aron Budea 2016-09-01 08:04:42 UTC
Hi! I checked Excel's description for COUNTA as well, and based on that it seems you're right, the circular reference can be eliminated based on this criteria: "The COUNTA function counts cells containing any type of information, including error values and empty text ("")".

So regardless of what the field with formula in the range evaluates to, it can be counted in COUNTA (I don't know what actually happens in Excel, this is just my deduction).

For reference and comparison:
https://support.office.com/en-us/article/COUNTA-function-7dc98875-d5c1-46f1-9a82-53f3219e2509
https://help.libreoffice.org/Calc/Statistical_Functions_Part_One#COUNTA

Adding needAdvice keyword to get input on this from developers.

Now that we discussed COUNTA, is anything wrong with COUNT?
Comment 9 Carlos 2017-04-04 15:07:57 UTC
Created attachment 132327 [details]
The original file saved as a MS Excel 2003 file
Comment 10 Carlos 2017-04-04 15:10:17 UTC
Created attachment 132328 [details]
The original file saved as a MS Excel 2007-2013 file
Comment 11 Carlos 2017-04-04 15:16:15 UTC
Can anyone test this files using MS Excel?
Does it warn about "circular references"?

I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested information is provided.
Comment 12 andis.lazdins 2017-04-04 15:27:26 UTC
(In reply to Carlos from comment #11)
> 
> I have set the bug's status to 'NEEDINFO'. Please change it back to
> 'UNCONFIRMED' once the requested information is provided.

In both cases Excel 2007 opens file with warning on circular references.
Comment 13 QA Administrators 2017-10-30 10:54:07 UTC Comment hidden (obsolete)
Comment 14 andis.lazdins 2017-10-30 11:08:34 UTC
Hello!

There is no inquiry for additional information. It was not decided, if this is bug or improvement. There is more or less easy workaround or switching to OpenOffice.org, therefore to me this report can be closed.

Regards
Comment 15 QA Administrators 2018-05-02 15:46:41 UTC Comment hidden (obsolete)
Comment 16 QA Administrators 2018-05-30 16:47:26 UTC Comment hidden (obsolete)
Comment 17 Aron Budea 2021-07-25 03:24:24 UTC
Seems like this was fixed by the same commits as bug 118161, in 6.2 / 6.1 / 6.0.5.