Bug 119980 - COUNTIF function doesn't return values when Criteria is set to a cell
Summary: COUNTIF function doesn't return values when Criteria is set to a cell
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.1.1.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-19 13:29 UTC by christopher.d.tan
Modified: 2018-09-19 17:11 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Spreadsheet with COUNTIF function (21.05 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-09-19 15:58 UTC, christopher.d.tan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description christopher.d.tan 2018-09-19 13:29:28 UTC
Example:

A1 = 3
A2 = 3
A3 = 5

COUNTIF(A1:A3,"3") will return 2.  However, if I populate a cell with 3 (i.e. B1) and call COUNTIF(A1:A3,B1), this returns 0.

Also, the documentation for this function says the syntax should be COUNTIF(<RANGE>;<CRITERIA>) but when I use this format, Calc changes the syntax to a comma delimiting the RANGE and CRITERIA.

i.e. enter COUNTIF(A1:A3;"3") and Calc returns COUNTIF(A1:A3,"3")
Comment 1 raal 2018-09-19 15:47:27 UTC
Works for me. Version: 6.2.0.0.alpha0+
Build ID: a27ae800fed5a974c9b255f7ce2b38ec2dbaa426
CPU threads: 4; OS: Windows 6.1; UI render: default; 

Please send us a sample document, as this makes it easier for us to verify the bug. I have set the bug's status to 'NEEDINFO', so please do change it back to 'UNCONFIRMED' once you have attached a document.
(Please note that the attachment will be public, remove any sensitive information before attaching it.)
How can I eliminate confidential data from a sample document?
https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F
Thank you
Comment 2 christopher.d.tan 2018-09-19 15:58:12 UTC
Created attachment 145022 [details]
Spreadsheet with COUNTIF function

Cells E3 =COUNTIF($B$3:$B$32,D11)
I forgot to add that B3:B32 uses the LEFT function.
Comment 3 Oliver Brinzing 2018-09-19 17:01:13 UTC
i had a look at your example:

- select menu "View/Value highlighting" first

- A3 contains a decimal number: 432,65
- B3 refers A3: =LEFT(A3;1)
- result is: 4 (text) 
  i didn't even know that this is working, cause
  Left() formula requires parameter: =Left(Text, Number)

- D3 contains a number: 1
- E3 refers D3: =COUNTIF($B$3:$B$32;D3)
  so you compare text with vaules ...

  -> change D3 to text, e.g. type '1 or format as Text @ and enter 1 again
Comment 4 Oliver Brinzing 2018-09-19 17:06:45 UTC
or change B3 to: =VALUE(LEFT(A3;1))
Comment 5 christopher.d.tan 2018-09-19 17:11:17 UTC
I truly appreciate the quick resolution and workaround.  Thank you for this information.