Countifs with uniques and wildcards and OR function

Country_Calc

New Member
Joined
Feb 14, 2017
Messages
48
Office Version
  1. 365
I am trying to count unique records that involve an OR function and other criteria.

Here is the query to be answered.

How many Names have either *MD Anderson*" OR "*Anderson*" have City as "Houston" and Variable of greater than 0.

I want to do something like this, but it does not work and does not take Unique result into account.

=SUM(COUNTIFS(C2:C8,"Houston",D2:D8,">0",B2:B8,{"*"&F2&"*","*"&G2&"*"}))

Please let me know if this is possible.

Unique ID NumberNameCityVariableName Query 1Name Query 2CountryDesired Result
6680M.D. Anderson InternacionalMadrid1MD AndersonAndersonHouston
2​
7632MD Anderson Cancer CenterHouston6
8587MD Anderson Cancer CenterMadrid0
8614MD Anderson Cancer CenterMadrid0
10076M.D. Anderson Cancer CenterHouston0
10077M.D. Anderson Cancer CenterHouston1
10078MD Anderson Cancer CenterHouston0
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try

Book5
ABCDEFGHIJ
1Unique ID NumberNameCityVariableName Query 1Name Query 2CountryDesired Result
26680M.D. Anderson InternacionalMadrid1MD AndersonAndersonHouston2
37632MD Anderson Cancer CenterHouston6
48587MD Anderson Cancer CenterMadrid0
58614MD Anderson Cancer CenterMadrid0
610076M.D. Anderson Cancer CenterHouston0
710077M.D. Anderson Cancer CenterHouston1
810078MD Anderson Cancer CenterHouston0
9
10
11
12
Sheet1
Cell Formulas
RangeFormula
I2I2=COUNTIFS(B2:B8,"*"&G2&"*",C2:C8,H2,D2:D8,">0")
 
Upvote 0
This might do OR well if your name queries are where one doesn't contain the other.

MrExcelPlayground15.xlsx
ABCDEFGHI
1Unique ID NumberNameCityVariableName Query 1Name Query 2CountryDesired Result
26680M.D. Anderson InternacionalMadrid1MD AndersonAndersonHouston2
37632MD Anderson Cancer CenterHouston6
48587MD Anderson Cancer CenterMadrid0
58614MD Anderson Cancer CenterMadrid0
610076M.D. Anderson Cancer CenterHouston0
710077M.D. Anderson Cancer CenterHouston1
810078MD Anderson Cancer CenterHouston0
Sheet14
Cell Formulas
RangeFormula
I2I2=LET(z,FILTER(C2:C8,D2:D8>0),a,FILTER(B2:B8,D2:D8>0),b,ISNUMBER(SEARCH(F2,a)),c,ISNUMBER(SEARCH(G2,a)),d,ISNUMBER(SEARCH(H2,z)),e,SIGN(b+c)*d,SUM(e))
 
Upvote 0
Solution
Try

Book5
ABCDEFGHIJ
1Unique ID NumberNameCityVariableName Query 1Name Query 2CountryDesired Result
26680M.D. Anderson InternacionalMadrid1MD AndersonAndersonHouston2
37632MD Anderson Cancer CenterHouston6
48587MD Anderson Cancer CenterMadrid0
58614MD Anderson Cancer CenterMadrid0
610076M.D. Anderson Cancer CenterHouston0
710077M.D. Anderson Cancer CenterHouston1
810078MD Anderson Cancer CenterHouston0
9
10
11
12
Sheet1
Cell Formulas
RangeFormula
I2I2=COUNTIFS(B2:B8,"*"&G2&"*",C2:C8,H2,D2:D8,">0")

The example I posted was not ideal because "*anderson*" would cover both wildcard text queries. Here is a better one for what I am trying to do.

Query is for "*University of California at Los Angeles*" or "*UCLA*"

Because 1 record has both terms in the same cell, I need to add in Unique somehow.

Unique ID NumberNameCityVariableName Query 1Name Query 2CountryDesired Result
6680University of California at Los Angeles (UCLA)Los Angeles1University of California at Los AngelesUCLALos Angeles3
7632UCLALos Angeles6
8587University of California at Los AngelesLos Angeles0
8614University of California (UCLA)Los Angeles1
 
Upvote 0
Try

Book5
ABCDEFGHIJ
1
2Unique ID NumberNameCityVariableName Query 1Name Query 2CountryDesired Result
36680University of California at Los Angeles (UCLA)Los Angeles1University of California at Los AngelesUCLALos Angeles3
47632UCLALos Angeles6
58587University of California at Los AngelesLos Angeles0
68614University of California (UCLA)Los Angeles1
7
8
9
10
11
Sheet3
Cell Formulas
RangeFormula
I3I3=SUMPRODUCT(ISNUMBER(MATCH("*"&G3&"*",$B$3:$B$9,0))*ISNUMBER(MATCH(H3,C3:C9,0))*(D3:D9>0)*ISNUMBER(MATCH("*"&F3&"*",$B$3:$B$9,0)))
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,830
Members
449,096
Latest member
Erald

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