Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count cells with question mark #328

Closed
Simounet opened this issue Apr 14, 2016 · 8 comments
Closed

Count cells with question mark #328

Simounet opened this issue Apr 14, 2016 · 8 comments

Comments

@Simounet
Copy link

Hi,
I'm trying to count the cell's number with a question mark at the end on a text (ex. Item 1 ? with =COUNTIF(A2:H49, '?'). It returns me the count of empty cells.
Is it a bug or did I miss something?

@eddyparkinson
Copy link
Collaborator

It accepts regx, this worked: =countif(C3:C6,"[?]+")
 ---
Eddy Parkinson PhD
Software Engineering and Logistics
Mobile 0406 962 958

New ideas pass through three periods: 1) It cant be done. 2) It probably can be done, but its not worth doing. 3) I knew it was a good
idea all along! - Arthur C. Clarke

On Thursday, 14 April 2016, 22:45, Simon Alberny <notifications@github.com> wrote:

Hi,
I'm trying to count the cell's number with a question mark at the end on a text (ex. Item 1 ? with =COUNTIF(A2:H49, '?'). It returns me the count of empty cells.
Is it a bug or did I miss something?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

@audreyt audreyt closed this as completed Apr 16, 2016
@ckhung
Copy link
Collaborator

ckhung commented Apr 16, 2016

Thank you, @eddyparkinson, nice tip! Is it correct if I add the link https://wiki.openoffice.org/wiki/Documentation/How_Tos/Regular_Expressions_in_Calc to the document? So for certain functions the string args are treated as regexp by default. Is there a way to turn it off?

@eddyparkinson
Copy link
Collaborator

Cleaner solution:    =countif(E7:E9,"=?")

Chao,   suggest you change the "function list" help to something along the lines of: 
  "The criteria may be a value (15, 1+3) or a test (">25","=x") or a regular expression ("a?", "[a-z]*")  
 The link, it is good to add a link, but I notice that includes "'MATCH', 'SEARCH', 'LOOKUP', 'HLOOKUP', 'VLOOKUP',"  And I don't think ethercalc  supports regex in these. 

Many functions are impacted, e.g.all these look be using:"The criteria may be a value (15, 1+3) or a test (">25","=x") or a regular expression ("a?", "[a-z]")  
/
## DAVERAGE(databaserange, fieldname, criteriarange)# DCOUNT(databaserange, fieldname, criteriarange)# DCOUNTA(databaserange, fieldname, criteriarange)# DGET(databaserange, fieldname, criteriarange)# DMAX(databaserange, fieldname, criteriarange)# DMIN(databaserange, fieldname, criteriarange)# DPRODUCT(databaserange, fieldname, criteriarange)# DSTDEV(databaserange, fieldname, criteriarange)# DSTDEVP(databaserange, fieldname, criteriarange)# DSUM(databaserange, fieldname, criteriarange)# DVAR(databaserange, fieldname, criteriarange)# DVARP(databaserange, fieldname, criteriarange)## Calculate all of these and then return the desired one (overhead is in accessing not calculating)# If this routine is changed, check the series_functions, too.#/
/
## COUNTIF(c1:c2,"criteria")# SUMIF(c1:c2,"criteria",[range2])#*/

adding =,>,<   causes everything after the operator to be treated as a string.  

Eddy Parkinson PhD
Software Engineering and Logistics
Mobile 0406 962 958

New ideas pass through three periods: 1) It cant be done. 2) It probably can be done, but its not worth doing. 3) I knew it was a good
idea all along! - Arthur C. Clarke

On Saturday, 16 April 2016, 11:32, Chao-Kuei Hung <notifications@github.com> wrote:

Thank you, @eddyparkinson, nice tip! Is it correct if I add the link https://wiki.openoffice.org/wiki/Documentation/How_Tos/Regular_Expressions_in_Calc to the document? So for certain functions the string args are treated as regexp by default. Is there a way to turn it off?—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@ckhung
Copy link
Collaborator

ckhung commented Apr 19, 2016

ok I looked at SocialCalc.Formula.TestCriteria in formula1.js and am inclined to write this: "if the criteria string does not begin with a comparison operator and dose contain ? or *, then it will be interpreted as an excel wildcard string or as a js regular expression. Please see the source code for a complete list of functions supporting regex." @audreyt, can you please confirm or correct me?

@audreyt
Copy link
Owner

audreyt commented Apr 19, 2016

That sounds about right. Thanks!

Chao-Kuei Hung notifications@github.com 於 2016年4月19日週二 10:44 寫道:

ok I looked at SocialCalc.Formula.TestCriteria in formula1.js and am
inclined to write this: "if the criteria string does not begin with a
comparison operator and dose contain ? or *, then it will be interpreted as
an excel wildcard string or as a js regular expression. Please see the
source code for a complete list of functions supporting regex." @audreyt
https://github.com/audreyt, can you please confirm or correct me?


You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#328 (comment)

Cheers,
Audrey

@Simounet
Copy link
Author

Thanks for your help but I don't get why it is not working in my case.
I've got many columns with

  • different names
  • empty cells
  • names ending with ?

I tried something like =countif(A2:H49,"=?")but it gaves me 0.

Any clue?

@eddyparkinson
Copy link
Collaborator

 names ending with ?
"=?" is for an exact match, not something ending with ?A regex will handle that case. I would advise using a blank spreadsheet to test a regex - as there is a bug that crashes the sheet if you enter an invalid regex

On Thursday, 21 April 2016, 3:29, Simon Alberny <notifications@github.com> wrote:

Thanks for your help but I don't get why it is not working in my case.
I've got many columns with

  • different names
  • empty cells
  • names ending with ?
    I tried something like =countif(A2:H49,"=?")but it gaves me 0.Any clue?—
    You are receiving this because you were mentioned.
    Reply to this email directly or view it on GitHub

@Simounet
Copy link
Author

I end up with this one =countif(A2:H49,".* [?]$") that works very well.

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants