Excel: Combining Unique and Sort functions

Posted on:  04/14/2021
Excel: Combining Unique and Sort functions

The UNIQUE function in Excel returns a list of unique values in a list or range. The SORT function in Excel sorts the contents of a range or array. The functions are great individually, but I frequently combine them. In the video below, I show Unique and Sort in seven different examples.

Who can use Unique and Sort functions?

The Unique and Sort function work with 

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel for iPad
  • Excel for iPhone
  • Excel for Android tablets
  • Excel for Android phones
Unique Function in Excel with text

Unique Function in Excel with text

Unique Function in Excel with numbers

Unique Function in Excel with numbers

Sort function in Excel

Sort Function in Excel

Sort function in Excel in descending order

Sort function in Excel with descending order

UNIQUE function Syntax and Arguments

The Unique function has three arguments. Two are optional. 


=UNIQUE (array, [by_col], [exactly_once])


  • array - Range or array from which to extract unique values.
  • by_col - [optional] How to compare and extract. By row = FALSE (default); by column = TRUE.
  • exactly_once - [optional] TRUE = values that occur once, FALSE= all unique values (default).

Unique vs. Distinct

The function is called the Unique function, but technically it is finding Distinct values. What is the difference between Distinct vs. Unique?

Unique values are the items that appear only once. Distinct values are all different items in a list. So something Unique is Distinct, but something Distinct may not be Unique. See my example below.

I have a list of names in A2 through A8

  • In B2 is the function =UNIQUE(A2:A8) which shows Distinct values. 
  • In C2 is the function =UNIQUE(A2:A8,,TRUE), which shows UNIQUE values. Mary is Unique since she in the dataset only one time. The third argument in the Unique function is set to TRUE, which is why only Unique and not Distinct show.
Unique vs. Distinct in Excel

Unique vs. Distinct

YouTube video

SORT function Syntax and Arguments

The SORT function has four arguments. Three are optional.


=SORT (array, [sort_index], [sort_order], [by_col])


  • array - Range or array to sort.
  • sort_index - [optional] Column index to use for sorting. Default is 1.
  • sort_order - [optional] 1 = Ascending, -1 = Descending. Default is ascending order.
  • by_col - [optional] TRUE = sort by column. FALSE = sort by row. Default is FALSE.
Sort with the second argument 2

Sort function with the second argument 2. Sorting by Salary, the second column.

Excel file to download

Here is the file used in the video.


Why not just use the sort feature, Data - Sort - instead of the SORT function?

With the SORT function, your data is always sorted in a the order you want. If you use the Data - Sort and change your data, you will need to sort your data again.With the SORT function the data is alway in the correct order.

Can't I find unique values with Remove Duplicates?

Remove duplicates is great, but if you change your data, remove duplicates does not change. With the Unique function, when your data changes, the Unique function shows the updated results.

Other Excel articles

Chris Menard

Chris Menard is a Senior Training Specialist at SurePoint Technologies. Chris is certified in Excel, Word, PowerPoint, and Outlook. Menard has a YouTube channel with other 600 technology videos covering Excel, Word, Zoom, Teams, Outlook, Gmail, Google Calendar, and other resources that over 7 million viewers have very appreciated. Because of Chris's certification and expertise with Microsoft, Chris is a proud member of Microsoft's Creator Team. Being a member of Microsoft's Creator Teams means many of his videos are available on Microsoft 365 YouTube channel and Microsoft support websites.