Count chars in a column [closed]

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

edit retag 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

Sort by » oldest newest most voted

Hallo

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


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

more

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?

more

Can't read anything about COUNTIF dependent from Current Time

( 2016-03-10 20:01:52 +0100 )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.

( 2016-03-10 20:19:18 +0100 )edit

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

( 2016-03-10 20:27:05 +0100 )edit

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

( 2016-03-10 20:37:13 +0100 )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

( 2016-03-11 18:22:51 +0100 )edit