Search
 
SCRIPT & CODE EXAMPLE
 

EXCEL

google sheets sort column by item frequency

# Basic syntax:
=SORT(A:A, COUNTIF(A:A, A:A), 0)
# Where:
#	- this will sort column A by the number of occurrences of each item
#		in column A
#	- COUNTIF($A:A, $A:A) only counts the occurrences of A1 in column A.
#		This is because COUNTIF is not an array formula. However, by
#		wrapping it inside the SORT function, that makes it behave as an
#		array formula, which causes it to return the count of each cell
#		in column A in column A
#	- SORT(A:A, ..., 0) sorts column A in descending order based on the
#		counts
# Note:
#	- if you want the unique occurrences of each item sorted by
#		frequency, wrap the sort function with UNIQUE()
#	- normally the second argument to SORT is the column number to sort
#		by, but it seems like if you provide an array of numbers of the
#		same length as the range, it uses those numbers first when
#		sorting, followed by any additional columns you specify
#	- the article this is based on uses IF(LEN(A:A), COUNTIF(...)). The
#		IF(LEN(A:A),,) part prevents the formula from including blank
#		cells, but isn't really necessary
Comment

PREVIOUS NEXT
Code Example
Excel :: google sheets countif current month 
Excel :: google sheets if 
Excel :: unhide rows in excel 
Excel :: excel or function 
Excel :: set row as header excel 
Perl :: perl exit loop 
Perl :: perl for 
Perl :: append string perl 
Perl :: perl exit loop example 
Pascal :: pascal wait for key 
Pascal :: array pascal 
Powershell :: powershell take ownership recursive command 
Powershell :: powershell scriptblock return variable 
Gdscript :: godot 3d slowly rotate towards object 
Abap :: Full screen ALV create with CL_GUI_ALV_GRID class 
Assembly :: Cannot open self /usr/local/bin/docker-compose 
Assembly :: how to check if chat is nsfw discord.py 
Assembly :: what do you mean by io address and memory address 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: week days array in javascrpt 
Javascript :: jquery redirect 
Javascript :: Javascript run code after page load 
Javascript :: react native reset cache 
Javascript :: moment get today, tomorrow, yesterday 
Javascript :: detect browser javascript 
Javascript :: javascript code to edit webpage 
Javascript :: react native rotate 
Javascript :: javascript loop through class elements 
Javascript :: js find object length 
Javascript :: javascript for loop over dictionary 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =