SOLVED

Need Help: Count a Cell Equals Exact Text ONLY IF another Cell Equals Exact Text

%3CLINGO-SUB%20id%3D%22lingo-sub-2671948%22%20slang%3D%22en-US%22%3ENeed%20Help%3A%20Count%20a%20Cell%20Equals%20Exact%20Text%20ONLY%20IF%20another%20Cell%20Equals%20Exact%20Text%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2671948%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20count%20cells%20in%20column%20%22K%22%20with%20a%20text%20value%20of%20%22P%22%20ONLY%20IF%20cells%20in%20column%20%22H%22%20have%20a%20text%20value%20of%20%22PT.%22%20This%20is%20my%20formula%20but%20it%20keeps%20returning%20the%20value%20%221%22%20when%20I%20know%20there%20are%202%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DCOUNT(K5%3AK166%2C%22P%22%2C(COUNTIF(H5%3AH166%2C%22PT%22)))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHelp%20appreciated.%20Thank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2671948%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2671964%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Help%3A%20Count%20a%20Cell%20Equals%20Exact%20Text%20ONLY%20IF%20another%20Cell%20Equals%20Exact%20Text%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2671964%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1134040%22%20target%3D%22_blank%22%3E%40MMHiggins%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat%20could%20be%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DCOUNTIFS(K5%3AK166%2C%22P%22%2CH5%3AH166%2C%22PT%22)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2671967%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Help%3A%20Count%20a%20Cell%20Equals%20Exact%20Text%20ONLY%20IF%20another%20Cell%20Equals%20Exact%20Text%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2671967%22%20slang%3D%22en-US%22%3EThat%20worked%2C%20Sergei.%20THANK%20YOU.%20I%20thought%20that%20was%20one%20of%20the%20first%20I%20tried%20but%20obviously%20not!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2671969%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Help%3A%20Count%20a%20Cell%20Equals%20Exact%20Text%20ONLY%20IF%20another%20Cell%20Equals%20Exact%20Text%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2671969%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1134040%22%20target%3D%22_blank%22%3E%40MMHiggins%3C%2FA%3E%26nbsp%3B%2C%20you%20are%20welcome.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20your%20initial%20formula%20do%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3DCOUNT(K5%3AK166%2C%22P%22%2C(COUNTIF(H5%3AH166%2C%22PT%22)))%20goes%20to%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3DCOUNT(K5%3AK166%2C%22P%22%2C5)%20assuming%20COUNTIF%20returns%205%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ECOUNT()%20counts%20numbers%20in%20values%20presented%20by%20arguments%20ignoring%20the%20rest.%20Thus%20that%20is%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E0%20(zero%20numbers%20in%26nbsp%3BK5%3AK166%2C%20all%20texts)%20%2B%200%20(%22P%22%20is%20text)%20%2B%201%20(5%20is%20number)%20%3D%201%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello,

 

I am trying to count cells in column "K" with a text value of "P" ONLY IF cells in column "H" have a text value of "PT." This is my formula but it keeps returning the value "1" when I know there are 2:

 

=COUNT(K5:K166,"P",(COUNTIF(H5:H166,"PT")))

 

Help appreciated. Thank you.

5 Replies

@MMHiggins 

That could be

=COUNTIFS(K5:K166,"P",H5:H166,"PT")
That worked, Sergei. THANK YOU. I thought that was one of the first I tried but obviously not!

@MMHiggins , you are welcome.

 

What your initial formula do:

=COUNT(K5:K166,"P",(COUNTIF(H5:H166,"PT"))) goes to

=COUNT(K5:K166,"P",5) assuming COUNTIF returns 5

COUNT() counts numbers in values presented by arguments ignoring the rest. Thus that is

0 (zero numbers in K5:K166, all texts) + 0 ("P" is text) + 1 (5 is number) = 1

@Sergei Baklan This is a bit above my skill level to understand but thank you for explaining. Could you please help with one more problem? I am trying to count the number of persons who speak English (Column "I") but only if they are unique (Column "C"). Some persons are listed more than one row. This too is not working for me. Can you possibly solve? Excel says I am missing an opening or closing parenthesis but when I insert it then says I have too many arguments.

 

=COUNTIFs(I5:I166,"Eng",(SUM(IF(FREQUENCY(IF(LEN(C5:C166)>0,MATCH(C5:C166,C5:C166,0),""),IF(LEN(C5:C166)>0,MATCH(C5:C166,C5:C166,0),""))>0,1))

 

Thank you again.

best response confirmed by MMHiggins (Occasional Contributor)
Solution

@MMHiggins 

With FREQUENCY() that could be

=SUM(  --( FREQUENCY( IF( LEN(C5:C166)>0, IF( I5:I166="Eng", MATCH(C5:C166,C5:C166,0))),  ROW(C5:C166) - ROW(C5) +1 ) >0))

If you are not on Excel 365 you shall use above formula as array one. i.e. use Ctrl+Shift+Enter instead of Enter.  Such formula is explained here Excel formula: Count unique text values with criteria | Exceljet

 

If you are on Excel 365 there are more simple ways to do the same, above formula shall be used as regulars one (just Enter).