Bug 121772 - =COUNTIF(range; "0") counts blank cells
Summary: =COUNTIF(range; "0") counts blank cells
Status: RESOLVED FIXED
Alias: None
Product: calligrasheets
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Slackware Linux
: NOR normal
Target Milestone: ---
Assignee: Alfredo Beaumont
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-11 18:45 UTC by Peter Hedlund
Modified: 2006-02-16 15:27 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Hedlund 2006-02-11 18:45:14 UTC
Version:           1.5-beta1 (using KDE KDE 3.5.1)
Installed from:    Slackware Packages

I have a range of cells that may be empty or contain numerical values from 0 and up (no decimals). I want to to count separately the cells with the value 0. Using COUNTIF(range; "0") counts cells with 0 and also blank cells. I have to use COUNTIF(range; "0")-COUNTBLANK(range) to get the result I want.

The behavior in KSpread is inconsistent with OOo Calc where COUNTIF(range; "0") gives the expected result.

To count the rest of the non-blank cells in my range I use COUNTIF(range; ">0") which behaves as expected.
Comment 1 Tomas Mecir 2006-02-16 15:27:01 UTC
SVN commit 510130 by mecir:

Condition functions should not match on empty cells.

Patch by Alfredo Beaumont - alfredo.beaumont at gmail dot com

BUG: 121772



 M  +2 -0      valuecalc.cc  


--- trunk/koffice/kspread/valuecalc.cc #510129:510130
@@ -1928,6 +1928,8 @@
 
 bool ValueCalc::matches (const Condition &cond, Value val)
 {
+  if (val.isEmpty())
+	return false;
   if (cond.type == numeric) {
     double d = converter->asFloat (val).asFloat();
     switch ( cond.comp )