count distinct values in spreadsheet

前端 未结 7 1882
独厮守ぢ
独厮守ぢ 2020-12-12 23:22

I have a Google spreadsheet with a column that looks like this:

City
----
London
Paris
London
Berlin
Rome
Paris

I want to count the appeara

7条回答
  •  佛祖请我去吃肉
    2020-12-13 00:03

    You can use the query function, so if your data were in col A where the first row was the column title...

    =query(A2:A,"select A, count(A) where A != '' group by A order by count(A) desc label A 'City'", 0)
    

    yields

    City    count 
    London  2
    Paris   2
    Berlin  1
    Rome    1
    

    Link to working Google Sheet.

    https://docs.google.com/spreadsheets/d/1N5xw8-YP2GEPYOaRkX8iRA6DoeRXI86OkfuYxwXUCbc/edit#gid=0

提交回复
热议问题