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 | | |
You can use the =UNIQUE() and =COUNTIF() functions to count the number of occurrences of different values in a column in Excel.
Use the COUNTIF function to count how many times a particular value appears in a range of cells.
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...
Use the =Countif function to count the number of times each unique entry appears in the original list.
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)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With