Reputation: 13
For a given list of items in a column,I want it to give me top 3 values based on their count.
I would expect Cat
, Dog
and Donkey
in another column.
Upvotes: 1
Views: 358
Reputation: 10573
Please use the following formula
=QUERY(QUERY(A2:A11,
"select A, count(A) where A is not null group by A limit 3 label count(A) ''"),
"select Col1")
(You can adjust ranges to your needs)
Functions used:
Upvotes: 1
Reputation: 81
IF you are using SQL you can get them using COUNT and then the fieldname. If you are using a language not built around storing data you could run a for loop that updates a count variable for each element in the list. ie:
for (int i =0; i++; i < list.length) {
if( list[i] == cat)
catCounter++;
if (list[i]) = dog)
dogCounter++;
.
.
.
}
Upvotes: 0