After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 703770 - countif always assumes wildcards on either side of condition
countif always assumes wildcards on either side of condition
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: Analytics
1.12.x
Other Linux
: Normal normal
: ---
Assigned To: Morten Welinder
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2013-07-08 09:03 UTC by Florian
Modified: 2013-07-10 16:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sample screenshot (60.81 KB, image/png)
2013-07-10 15:02 UTC, Andreas J. Guelzow
Details
gnumeric sheet with countif examples (1.87 KB, application/x-gnumeric)
2013-07-10 16:04 UTC, Florian
Details

Description Florian 2013-07-08 09:03:27 UTC
[I know it does not belong in a bug report, but first I'd like to tell you: I really like gnumeric, it is a very nice spreadsheet program. Thanks for providing this alternative!]

I'd like to count the number of items ending on a string. According to
[http://office.microsoft.com/en-001/excel-help/countif-function-HP010069840.aspx], a condition like

=COUNTIF(A2:A7,"*es")

would count the number of cells ending with the letters "es" in cells A2 through A7. However, in gnumeric it counts all cells containing "es", no matter if =COUNTIF(A2:A7,"*es"), =COUNTIF(A2:A7,"*es*"), or =COUNTIF(A2:A7,"es") is used.
Comment 1 Florian 2013-07-08 09:05:26 UTC
according to https://projects.gnome.org/gnumeric/doc/gnumeric-function-COUNTIF.shtml COUNTIF is Excel compatible
Comment 2 Florian 2013-07-08 09:10:38 UTC
Maybe it is relevant: In OpenOffice the matching behavior can be defined in the options.

http://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_COUNTIF_function
Comment 3 Morten Welinder 2013-07-08 17:24:23 UTC
Do you have a sample sheet?  Prefereably stating which cell you want which
value in.
Comment 4 Morten Welinder 2013-07-10 14:14:46 UTC
This works fine for me with current git version.  (Nothing relevant has
changed since last stable release.)

a1=Jesper
a2=apples
b1=countif(a1:a2,"es")        ---> 0
b2=countif(a1:a2,"*es")       ---> 1
b3=countif(a1:a2,"*es*")      ---> 2

If you still see a problem, please reopen with a concrete example.
Comment 5 Andreas J. Guelzow 2013-07-10 15:02:24 UTC
Created attachment 248840 [details]
sample screenshot

There are strange things going on, see screenshot. C2 is 2 but you (Morten) seem to see 1.
Comment 6 Andreas J. Guelzow 2013-07-10 15:06:10 UTC
I see wit current git:

a1=Jesper
a2=apples
b1=countif($a$1:$a$2,"es")        ---> 0
b2=countif($a$1:$a$2,"*es")       ---> 2
b3=countif($a$1:$a$2,"*es*")      ---> 2
b4==countif(A1:A2,"*es")          ---> 2
Comment 7 Morten Welinder 2013-07-10 15:45:54 UTC
This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.
Comment 8 Florian 2013-07-10 16:04:46 UTC
Created attachment 248847 [details]
gnumeric sheet with countif examples

The statement in my bug report >> .. it counts all cells containing "es", no matter if "*es", "*es*", or "es" is used. << is not entirely correct. In fact, in my gnumeric it just acts as if always a "*" is appended to the pattern.

An extended example:
a1=Jesper
a2=apples
a3=ester
a4=es

countif($A$1:$A$4,"es")           --> 2     [should be 1]
countif($A$1:$A$4,"*es")          --> 4     [should be 2]
countif($A$1:$A$4,"es*")          --> 2     [correct]
countif($A$1:$A$4,"*es*")         --> 4     [correct]

Morten, could you try with the appended sheet?
Comment 9 Florian 2013-07-10 16:05:55 UTC
Great, thank you for the prompt replies.