Search code examples
google-sheetsuniquecountingflattengoogle-query-language

Google Sheets - Using Query with Count


I have data in I3:Z which I have assigned a named range to - "Data".

I have the following formula:

=QUERY(UNIQUE(FLATTEN(Data)))

Which returns a list of all the unique data entries.

I want to also add a count into the formula, so it shows how many times each data entry appears, and then sort the entire result by said number.

Thanks


Solution

  • use:

    =QUERY(FLATTEN(Data); 
     "select Col1,count(Col1)
      where Col1 is not null 
      group by Col1 
      order by count(Col1) desc 
      label count(Col1)''")