Pergunta

I have this issue: here is my table

ColA  ColB      
te     Y
te     Y
alo    
te     Y
te     
bb     Y
aa     Y

I want to count how many records in ColA, which has value "Y" in Col B. and if two duplicate record in A that also have same Y then just count one. (in this case, te record we just count one time) Many thanks

Foi útil?

Solução

I am not sure is there is a simple formula to achieve what you want, though it may be possible with an array formula of some kind.

The simplest way in my view would be:

  1. Select your data
  2. Select Data > Filter > Advanced Filter
  3. Check the Unique Records Only checkbox
  4. Select a range you would like to copy the results to in Copy to
  5. Now hit OK
  6. Now use =COUNTIF with criteria =Y to get number of unique records that also have Y

Edit - Array Formula Solution

I did some googling and found a site that shows how to return unique rows using an array formula. See here.

We can use that to return all unique rows in your rows in columns A and B, including rows where column B is blank. (I assume your data is in cell A2:B8)

=SUM(IF(((MATCH(A2:A8&B2:B8,A2:A8&B2:B8,0)) >=(ROW(A2:A8)-(MIN(ROW(A2:A8))-1)))=TRUE,1,0))

Once we know the total number of unique rows, if we subtract from that number the cells in column B that are blank (i.e. not equal to Y) then this should give us the total number of unique rows that have a Y in column B. We can now update the above formula as follows:

=SUM(IF(((MATCH(A2:A8&B2:B8,A2:A8&B2:B8,0)) >=(ROW(A2:A8)-(MIN(ROW(A2:A8))-1)))=TRUE,1,0)) - COUNTIF(B2:B8,"<>Y")

Type this formula in C1 and then press CTRL + SHIFT + ENTER as this is an array formula.

I tested this and it seemed to work ok.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top