Issue 25654 - Wrong results in COUNTIF
Summary: Wrong results in COUNTIF
Status: CLOSED IRREPRODUCIBLE
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: OOo 1.1
Hardware: PC Windows XP
: P3 Trivial (vote)
Target Milestone: ---
Assignee: spreadsheet
QA Contact: issues@sc
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-18 19:43 UTC by clodoveu
Modified: 2004-02-20 13:30 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Spreadsheet (.sxc) showing the described issue (4.60 KB, application/octet-stream)
2004-02-18 19:46 UTC, clodoveu
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description clodoveu 2004-02-18 19:43:58 UTC
COUNTIF returns erroneous results when used with regular expressions, in 
particular when the "*" wildcard is involved. An example: the pattern "4*" 
fails to match cells which contain "4A", "4AA" or "4B"; meanwhile, the 
pattern "4A*" matches "4A" and "4AA".
Comment 1 clodoveu 2004-02-18 19:46:41 UTC
Created attachment 13272 [details]
Spreadsheet (.sxc) showing the described issue
Comment 2 frank 2004-02-20 10:38:40 UTC
Hi,

this is not a bug of OOo Calc.

Just switch on the option 'Enable regular expressions in formulas' under tools
options spreadsheet calculate. Make also sure that you use the correct syntax
for regular expressions.

Frank
Comment 3 frank 2004-02-20 10:38:58 UTC
closed wfm
Comment 4 frank 2004-02-20 13:30:45 UTC
Hi,

extract from a PM :

In the file I supplied, the pattern "4." matches "4A" and "4B", producing "2" as
a result. The problem is that while "4." works, "4*" fails to match any of the
cells that have contents beginning with "4", as expected, resulting in a "0"
response.

----

Ok, if the reg. expressions are switched on, the second part of my answer comes
true.

the * alone is not a valid regular expression. To achieve your goal, the
formulas must have this form :

=COUNTIF(A1:A6;"4.*")
=COUNTIF(A1:A6;"4.")
=COUNTIF(A1:A6;"4A.*")
=COUNTIF(A1:A6;".*A")

Hope this sheds some light on it.

Frank