Ask Your Question
0

Count chars in a column [closed]

asked 2016-03-08 18:42:56 +0200

paparucino gravatar image

Hi all, Im new to libreoffice calc so, pls, be patient. I have a column which may contain only "M"s if the event is in the morning or only "P"s if its in the noon. I need to count the occurences of "M" or "P". What Im able to to is =COUNTIF(J6:J314,"=M") but Im not able to do the OR . Something like: Count the occurences of "M" or "P" in the range J6:J314

Thank youin advance paparucino

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by paparucino
close date 2016-03-11 18:23:20.112479

2 Answers

Sort by » oldest newest most voted
0

answered 2016-03-10 20:06:58 +0200

karolus gravatar image

updated 2016-03-10 20:08:59 +0200

Hallo

=COUNTIF( J6:J314 , "M|P" )

check →Tools→Options→Calc→calculate→→[x]allow regular Expressions ...

edit flag offensive delete link more
0

answered 2016-03-10 19:14:02 +0200

Ratslinger gravatar image

Hello, I may have made this more complex than it needs to be but here goes.

=IF(HOUR(NOW())<12,COUNTIF(J6:J314,"M"),COUNTIF(J6:J314,"P"))

This checks if the current time is less than noon and if it is looks for "M"'s and gives a count and if not it looks for "P"'s and gives a count. Is this what you are looking for?

edit flag offensive delete link more

Comments

Can't read anything about COUNTIF dependent from Current Time

karolus gravatar imagekarolus ( 2016-03-10 20:01:52 +0200 )edit

The question is somewhat confusing - Column contains only M or P (nothing else so you already have count it's # of rows). "...need to count occurences of "M" or "P"" not M & P. Just not clear.

Ratslinger gravatar imageRatslinger ( 2016-03-10 20:19:18 +0200 )edit

The real answer here may be one count of M's and one count of P's.

Ratslinger gravatar imageRatslinger ( 2016-03-10 20:27:05 +0200 )edit

Yes, if there is nothing else, we can simply =COUNTA(J6:J314)

karolus gravatar imagekarolus ( 2016-03-10 20:37:13 +0200 )edit

Im really sorry, I was hasty and didnt read correctly the first karolus answer (=COUNTIF( J6:J314 , "M|P" )). I made the modifications he suggested in Tools.... and everything is OK.

Thank you guys for you answers

paparucino gravatar imagepaparucino ( 2016-03-11 18:22:51 +0200 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-08 18:42:56 +0200

Seen: 36 times

Last updated: Mar 10 '16