count distinct values in spreadsheet

前端 未结 7 1870
独厮守ぢ
独厮守ぢ 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-12 23:51

    Link to Working Examples

    Solution 0

    This can be accompished using pivot tables.

    Pivot table Example - Count rows by value

    Solution 1

    Use the unique formula to get all the distinct values. Then use countif to get the count of each value. See the working example link at the top to see exactly how this is implemented.

    Unique Values        Count
    =UNIQUE(A3:A8)       =COUNTIF(A3:A8;B3)
                         =COUNTIF(A3:A8;B4)
                         ...
    

    Solution 2

    If you setup your data as such:

    City    
    ----    
    London   1
    Paris    1
    London   1
    Berlin   1
    Rome     1
    Paris    1
    

    Then the following will produce the desired result.

    =sort(transpose(query(A3:B8,"Select sum(B) pivot (A)")),2,FALSE)
    

    I'm sure there is a way to get rid of the second column since all values will be 1. Not an ideal solution in my opinion.

    via http://googledocsforlife.blogspot.com/2011/12/counting-unique-values-of-data-set.html

    Other Possibly Helpful Links

    • http://productforums.google.com/forum/#!topic/docs/a5qFC4pFZJ8

提交回复
热议问题