Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting number of occurrences in column?

What would be a good approach to calculate the number of occurrences in a spreadsheet column? Can this be done with a single array formula?

Example (column A is input, columns B and C are to be auto-generated):

|   A   |   B   |   C   | +-------+-------+-------+ | Name  | Name  | Count | +-------+-------+-------+ | Joe   | Joe   |     2 | | Lisa  | Lisa  |     3 | | Jenny | Jenny |     2 | | Lisa  |       |       | | Lisa  |       |       | | Joe   |       |       | | Jenny |       |       | 
like image 934
feklee Avatar asked Aug 25 '12 21:08

feklee


People also ask

How do I count occurrences in Excel column?

You can use the =UNIQUE() and =COUNTIF() functions to count the number of occurrences of different values in a column in Excel.

How do you count the number of times a value appears in a column?

Use the COUNTIF function to count how many times a particular value appears in a range of cells.

How do you count the number of occurrences in a cell?

The LEN function is fully automatic. In the example, the formula in the active cell is: = LEN ( B5 ) The LEN function simply counts all characters that appear in a cell. All characters are counted, including space characters, as you can see in cell...

How do you count occurrences of items in a list Excel?

Use the =Countif function to count the number of times each unique entry appears in the original list.


2 Answers

A simpler approach to this

At the beginning of column B, type

=UNIQUE(A:A) 

Then in column C, use

=COUNTIF(A:A, B1) 

and copy them in all row column C.

Edit: If that doesn't work for you, try using semicolon instead of comma:

=COUNTIF(A:A; B1) 
like image 145
Richard Wong Avatar answered Oct 20 '22 07:10

Richard Wong


Try:

=ArrayFormula(QUERY(A:A&{"",""};"select Col1, count(Col2) where Col1 != '' group by Col1 label count(Col2) 'Count'";1))


22/07/2014 Some time in the last month, Sheets has started supporting more flexible concatenation of arrays, using an embedded array. So the solution may be shortened slightly to:

=QUERY({A:A,A:A},"select Col1, count(Col2) where Col1 != '' group by Col1 label count(Col2) 'Count'",1)

like image 26
AdamL Avatar answered Oct 20 '22 09:10

AdamL