Search code examples
google-sheetsgoogle-sheets-formulacountinggoogle-sheets-querygoogle-query-language

How can I see how many times a username has appeared without counting manually


I've exported a list of customers, I need to find out the average subscription rate of each one. I have a list of about 2,000 transactions in alphabetical order. How can I find out how many times they appeared without counting manually?

Each transaction has a username, so I assume that there is some code that can take all the usernames and in the column next to them assign a number of how many times they have appeared on the sheet (This would tell me how many months they have paid)

This is an example:

Albert  | PAID
John    | PAID
John    | PAID
John    | PAID
John    | PAID
Tristan | PAID
Tristan | PAID

What I need help with is to get this result:

Albert: 1
John: 4
Tristan: 2 

manually counting would cost too much precious time :)

Thank you very much for tackling this!


Solution

  • =QUERY(A:A, 
     "select A,count(A) 
      where A is not null 
      group by A 
      label count(A)''", 0)
    

    enter image description here


    =QUERY(A:B, 
     "select A,count(A) 
      where B = 'PAID' 
      group by A 
      label count(A)''", 0)
    

    0