Problem with COUNTIF and wild character

alex_a

Board Regular
Joined
Feb 27, 2012
Messages
51
Good Morning,

I have the follwoing data in column C and D. in the C column i have multiple codes all of them start with the word QC. I need to count the numebr of "yes" in the column D. I am using an array formula like this:
SUMPRODUCT(C1:C20="QC*")*(D1:D20="Yes"). I get an erroo message (#Name!). What is wrong with this formula? Thanks.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Sumproduct won't support wildcard use like that.

And you ENDED the sumproduct with the first ), which left (D1:D20="Yes)" as a standalone function..
SUMPRODUCT(C1:C20="QC*")*(D1:D20="Yes")

Which version of Excel are you using?
In XL2007 we have COUNTIFS
=COUNTIFS(C1:C20,"QC*",D1:D20,"Yes")
 
Upvote 0

taurean

Well-known Member
Joined
Jun 17, 2011
Messages
2,190
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
COUNTIFS will be faster.

But if you intend to use SUMPRODUCT then you will have to use construct like below:
=SUMPRODUCT((LEFT(C1:C20,2)="QC")*(D1:D20="Yes"))
 
Upvote 0

CodeNinja

Well-known Member
Joined
Feb 18, 2013
Messages
644
ADVERTISEMENT
If you know it always starts with a QC then just use the left function...
Also, you need to convert the trues and falses to 0's and 1's.

=SUMPRODUCT(--(LEFT(C1:C20,2)="QC")*(--(D1:D20="Yes")))
 
Upvote 0

taurean

Well-known Member
Joined
Jun 17, 2011
Messages
2,190
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
If you know it always starts with a QC then just use the left function...
Also, you need to convert the trues and falses to 0's and 1's.

=SUMPRODUCT(--(LEFT(C1:C20,2)="QC")*(--(D1:D20="Yes")))
Double unaries are not required as * [multiplication] will coerce it to numbers.
 
Upvote 0

alex_a

Board Regular
Joined
Feb 27, 2012
Messages
51
ADVERTISEMENT
COUNTIFS will be faster.

But if you intend to use SUMPRODUCT then you will have to use construct like below:
=SUMPRODUCT((LEFT(C1:C20,2)="QC")*(D1:D20="Yes"))

Thanks. It worked liek a charm.
 
Upvote 0

alex_a

Board Regular
Joined
Feb 27, 2012
Messages
51
Thanks. It worked liek a charm.
I hav eanother question: If I want ato add another condition such as if the wild character is QC or blank, how can I modify the sumproduct or countif statement? Thanks.
 
Upvote 0

jai9

Active Member
Joined
Jul 20, 2012
Messages
325
Maybe,

=SUMPRODUCT((LEFT(C1:C10,2)="QC")*(E1:E10="Yes"))+SUMPRODUCT((C1:C10="")*(E1:E10="Yes"))

Jai
 
Upvote 0

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,210
I hav eanother question: If I want ato add another condition such as if the wild character is QC or blank, how can I modify the sumproduct or countif statement? Thanks.

=SUMPRODUCT(--ISNUMBER(MATCH(LEFT(C1:C10,2),{"QC",""},0)),--(E1:E10="Yes"))
 
Upvote 0

Forum statistics

Threads
1,195,650
Messages
6,010,915
Members
441,572
Latest member
keobongda8812

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
Top