Monday, December 12, 2016

GoogleSheets: Find the number of occurrences in the column

I love 'uniq -c' Linux command because it returns all the unique values along with their occurrences count.
I wanted do the same from Google Sheets. This is how I do it.

Let's say I have a list of fruits in Column A. There are repetitions and I would like to find the number of their occurrences.

Step1: Go to cell C1 and enter the formula '=UNIQUE(A:A)' . It returns all the unique items on column A.


Step2: Go to Cell D1 and enter the header 'Count'. Go to Cell D2 and enter a formula '=COUNTIF(A:A,C2)' .  It counts the number of occurrences of the unique items listed in Column C.


Isn't that easy?