COUNTIFS Incorrectly Returning 0

Rachel_D

New Member
Joined
Jul 12, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have two columns of data showing ordered shirt sizes and gifted shirt sizes, please see below. I entered each row by hand for this example, but double checked that no hidden characters are present via the trim() function. The formula =COUNTIFS(B2:B30, "S", C2:C30, "S") is returning a zero. I have changed columns B and C to text, general, etc. and nothing is fixing this issue. I thought perhaps the blanks were causing an error, but when I changed the ranges to match the shorter C column =COUNTIFS(B2:B11, "S", C2:C11, "S"), the formula is still incorrectly returning a zero. Thank you in advance for any assistance!

Row NumberShirt SizeGifted Shirt Size
2​
SM
3​
MS
4​
LS
5​
SM
6​
LL
7​
LS
8​
SL
9​
SM
10​
LS
11​
SL
12​
M
13​
L
14​
S
15​
M
16​
L
17​
S
18​
M
19​
M
20​
S
21​
M
22​
L
23​
L
24​
L
25​
L
26​
S
27​
M
28​
M
29​
S
30​
S
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Welcome to the Board!

It appears to be working correctly to me.
Your COUNTIFS formula will only count it if the "S" appears in both columns in the same row.
(Note what the COUNTIFS function does is count how many ROWS meet ALL your conditions!)
You do not have any rows in your example meeting both those conditions.

What exactly are you trying to count?
 
Upvote 1
@Rachel_D What do you expect? Do you want to count of "S" in the first column if the second column corresponding cell is blank or "S"? Or do you want a count of all "S" in the entire range?
 
Upvote 1
Welcome to the Board!

It appears to be working correctly to me.
Your COUNTIFS formula will only count it if the "S" appears in both columns in the same row.
(Note what the COUNTIFS function does is count how many ROWS meet ALL your conditions!)
You do not have any rows in your example meeting both those conditions.

What exactly are you trying to count?
Thank you for the warm welcome and the speedy reply! I didn't realize COUNTIFS counted only when conditions are met in same row - this makes perfect sense now! I just wanted to count all the "S"s present in both columns, so a formula that will return 14 based on the sample data above. Thank you again, I really appreciate it!
 
Upvote 0
then try this:
Excel Formula:
=SUM(--("S"=B2:C11))
or
Excel Formula:
=COUNTIF(B2:C11,"S")

(NOTE: I count 15 "S" in the above, is there some kind of exclusion process i've missed?)
 
Upvote 1
Solution
Thank you for the warm welcome and the speedy reply! I didn't realize COUNTIFS counted only when conditions are met in same row - this makes perfect sense now! I just wanted to count all the "S"s present in both columns, so a formula that will return 14 based on the sample data above. Thank you again, I really appreciate it!
Just use a COUNTIF to count all the "S" values in that entire range, i.e.
Excel Formula:
=COUNTIF(B2:C30,"S")
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top