Numbers - Countifs - Using 'or'

I'm creating a graph to count if one of multiple conditions are true, but I cannot figure out how to express that in a formula. With countifs, I only see the formula expressed as "countifs (test-values, condition, test-values, condition)" in which all conditions must be true for it to be counted.


I know that I can make multiple cells to count each condition and then find the sum of those totals, but with the information I have set up, this will make the tables/graphs particularly messy and confusing.


Let's say I want to count how many times "A" "C" or "F" are used in a column, can someone recommend the formula to express this?


Thanks

MacBook Pro 13″, macOS 11.6

Posted on Nov 6, 2021 4:15 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 6, 2021 5:52 PM

=COUNTIFS(B,REGEX("[acf]"))

This will work if it really is just one character per cell as in your example. It will also count words like "battery" because it has an "a" in it.


This one will do single characters

=COUNTIFS(B,REGEX("^[acf]$"))

or

=COUNTIFS(B,REGEX("^(a|c|f)$"))


This one will count cells that have the specified "words" and nothing else. In this case it the "words" are abc, cba, and fab, all case sensitive:

=COUNTIFS(B,REGEX("^((abc)|(cba)|(fab))$"))

7 replies
Question marked as Top-ranking reply

Nov 6, 2021 5:52 PM in response to Frederic_Neige

=COUNTIFS(B,REGEX("[acf]"))

This will work if it really is just one character per cell as in your example. It will also count words like "battery" because it has an "a" in it.


This one will do single characters

=COUNTIFS(B,REGEX("^[acf]$"))

or

=COUNTIFS(B,REGEX("^(a|c|f)$"))


This one will count cells that have the specified "words" and nothing else. In this case it the "words" are abc, cba, and fab, all case sensitive:

=COUNTIFS(B,REGEX("^((abc)|(cba)|(fab))$"))

Nov 6, 2021 4:51 PM in response to Barry

Ah! I see the confusion. Let me clarify… in the example, i would say, the cells only contain single letters… such as: A, B, C, D, E, F, G… etc. Please reference the table attached for clarity in my example. I’m trying to create a countifs formula in one column for more than one condition. So in this table, how can i count how many times “A” “C” and “F” are used in column B?


Nov 6, 2021 5:59 PM in response to Badunit

The last one should have read "will count cells that have any one of the specified words and nothing else"


I'm no expert with regular expressions so let me know if any of those don't work as intended.


Summing a few countifs is more straightforward than REGEX in this particular case but REGEX can do more sophisticated things.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Numbers - Countifs - Using 'or'

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.