How to use the unique function in Microsoft Excel

The UNIQUE function in Microsoft Excel does exactly as its name suggests: it extracts unique values ​​from an array. In other words, you will only see each value once in the result, even if it appears multiple times in the source. Let’s take a look at how it works, how to use it, and how to avoid some of the risks.

UNIQUE functionality is available to those using Excel for Microsoft 365, Excel for the web, Excel mobile and tablet apps, and unique versions of Excel released in 2021 or later.

Operating system

Windows, Mac, iPhone, iPad, Android

Brand

Microsoft

Microsoft 365 includes access to Office apps like Word, Excel, and PowerPoint on up to five devices, 1 TB of OneDrive storage, and more.


Unique function syntax

The UNIQUE function in Excel has three arguments—one required and two optional:

=UNIQUE(a,b,c)

where

  • A is the array from which you want to return unique values,
  • for A logical value that specifies whether unique rows (FALSE) or columns (TRUE) are returned, and
  • C It is also a logical value, but this time it specifies whether all unique values ​​(FALSE) or those that occur only once (TRUE) will be returned.

If you delete the arguments for wow CFALSE is assumed to be the default. This means that only the argument is entered A It means that all unique rows in the array will be returned.

The default behavior of the unique function in Excel is to extract an array while removing duplicates in the process. In other words, even if a value appears more than once in the source data, it will only appear once in the result. You can use this function on a one-dimensional array (one column or row) or a two-dimensional array (two or more columns or rows). Here’s how.

To continue while reading this guide, Download a free copy of the Excel workbook used in the examples. After you click the link, you’ll find a download button in the upper-right corner of your screen, and when you open the file, you can access each example on a separate worksheet tab.

The UNIQUE function is commonly used to clean up a one-dimensional array that contains duplicate entries.

In this spreadsheet, the table named T_PLWinners Lists all Premier League champions since 2010.

An Excel table with the years (in descending order) in column A, and the Premier League winners in column B.

The UNIQUE function is case insensitive. This means that it will be treated Geek, Geekand obsessed With the same text string.

Since the source data contains duplicate values ​​because some teams have won the title more than once, your goal is to create a cleaner list that lists each winner only once. In other words, you want to apply the UNIQUE function to the Winner column in the T_PLWinners table. To do this, in cell D2, type:

=UNIQUE(T_PLWinners[Winner])

And press Enter.

Instead of manually typing the structured reference for the column header, hover the mouse pointer over the column header until you see a small black down arrow, and then click once to select the entire column.

Unique function used in Excel to extract a list of distinct values ​​from the winner column in the winners table in PL.

In this case, there is no need to provide arguments for and C Because you want to return all unique rows in the array, which is the default behavior. However, if the team list is in Row 2 instead of Column B, you will need to type TRUE For the argument for.

The unique function in Excel is a dynamic array function, which means that the result goes from the cell in which you typed the formula. This also means that as more rows of data are added to the source table, the result is updated to reflect the changes.

Extract unique values ​​from two or more columns or rows

The UNIQUE function in Excel can also be applied to two or more columns or rows at a time to return unique combinations.

Let’s say you want to extract the first and last names of all award winners from this named table T_Prizesbut only once if they win multiple prizes.

An Excel table with years in column A, first names in column B, and last names in column C.

The principle is remarkably similar to extracting unique values ​​from a one-dimensional array, the only change being the cells referenced in the argument A:

=UNIQUE(T_Prizes[[First]:[Last]])
The UNIQUE function in Excel is used to extract unique rows from a table, with two columns displayed in the result.

Notice how the formula refers to both the column with the first heading and the column with the last heading. Also, although there are two names in the source data, they are listed as unique names, as they are paired with different surnames.

If you select all columns in a formatted table for the argument AA structured reference contains only the table name, not the column headers.

If, after extracting distinct values, you want to convert the result from a dynamic array to a static array, select the cells, press Ctrl+C to copy them, and then press Ctrl+Shift+V to paste them as values. This removes the formula but keeps the cell contents.

Use the same method to extract unique column-based groups, but remember to type TRUE For the argument for.

Use the unique function to return values ​​that appear only once

When you ignore the argument C In the UNIQUE function, the result includes all distinct values, whether they appear once or multiple times in the source data. However, write TRUE For the argument C Forces Excel to return a list of values ​​that appears only once.

The table below is named T_transactionsand you want to contact all customers who have made just one transaction with you.

An Excel table with transaction IDs in column A, and customer names in column B.

This is where the final argument to the UNIQUE function comes into play:

=UNIQUE(T_Transactions[Customer],,TRUE)
The final argument to the UNIQUE function in an Excel spreadsheet is TRUE, which means that only values ​​that appear once are returned in the result.

Type TRUE for the arguments for and C In the same formula, columns whose unique values ​​appear are returned only once.

Use the unique function alongside other Excel functions

The power of Excel’s unique functionality becomes truly evident when combined with other functions.

All examples below use the argument only A For a unique formula, although you can apply the same principles to unique formulas whose arguments are for wow C The non-default logical value, TRUE.

Count and Unique: Calculate unique values

Nesting UNIQUE into COUNTA counts the number of unique values ​​in the array.

This table, called T_PremChamp, lists the Premier League winners in each season since 2010. You want to use this data to determine how many different teams have won the Premier League in that period.

An Excel table with the years in column A, and the Premier League winners in column B.

In the following formula, the UNIQUE function produces a theoretical list of all teams without any duplicates, and the COUNTA function counts the number of cells that this theoretical list will occupy:

=COUNTA(UNIQUE(T_PremChamp[Winner]))
The COUNTA and UNQUE functions are used together in an Excel formula to count the number of unique values ​​in an array.

Since UNIQUE is a dynamic array function, the resulting value will increase if a new team is added to the table.

Sort and Unique: Extract and sort unique values

When used alone, the UNIQUE function returns values ​​in the order in which they appear in the original data set. For example, use UNIQUE to return all unique values ​​from the WINNER column T_premew The table here returns Chelsea as the third value, even though it is closest to A alphabetically.

The UNIQUE function in Excel is used to extract unique football teams from the winners list.

To fix this, you need to merge the above unique formula inside SORT. This forces Excel to create a theoretical list of unique values, and the SORT function returns this list in alphabetical order:

=SORT(UNIQUE(T_PremW[Winner]))
The SORT and UNIQUE functions are used together in Excel to extract an ordered list of unique values ​​from a table column.

Unique and Filter: Extract unique values ​​based on criteria

The FILTER function in Excel allows you to extract values ​​from a data set based on certain criteria you set. Nesting it within UNIQUE means that if a given value matches the criteria more than once, it will not be repeated in the result.

In this example, the names of all winners who received more than 50% of the votes in a given year are extracted from T_sounds table using the FILTER function.

=FILTER(T_Votes[Name],T_Votes[Vote%]>0.5)
Excel's filter function is used to extract the names of all employees from the table who received more than 50 percent of the votes.

However, Patricia Naylor appears more than once in the data source, that is, it appears more than once in the result. So, to fix this problem, and return each name only once, merge the formula inside UNIQUE:

=UNIQUE(FILTER(T_Votes[Name],T_Votes[Vote%]>0.5))
UNIQUE and FILTER are used together in Excel to produce a list of non-duplicate names of individuals who received more than fifty percent of the votes.

If you want the result of the unique filtered list to be alphabetically, merge the entire formula inside SORT.

UNIQUE, FILTER, AND COUNTIF: Extract values ​​that occur more than once

In the final example, the UNIQUE function can be used in conjunction with FILTER and COUNTIF to extract values ​​that occur more than once.

Here, the names of individuals whose names appear at least twice are extracted using this formula:

=UNIQUE(FILTER(T_PWin[Name],COUNTIF(T_PWin[Name],T_PWin[Name])>1))
UNIQUE, FILTER, and COUNTIF functions used in Excel to extract the names of people from a table who have won an award more than once.

Using FILTER and COUNTIF will only include names that appear at least twice, but will be repeated in the result.

The FILTER and COUNTIF functions are used in Microsoft Excel to extract the names of people who have won more than one award into a database.

Therefore, the UNIQUE function removes these duplicates to ensure that each name appears only once.

Use >2 in the final argument of the formula to extract values ​​that occur more than twice, >3 for those that occur more than three times, and so on.

Issues you may encounter when using UNIQUE in Excel

As with all functions in Excel, some scenarios and environments prevent it from working as you expect. Here are some hurdles you may face, and what you can do to jump them:

problem

What does this mean

What to do

Do you see #NAME? mistake.

The version of Excel that you are using does not support the UNIQUE function.

Switch to Excel for Microsoft 365, Excel for the webOr Excel mobile and tablet apps, or unique versions of Excel released in 2021 or later, and then try again.

See #SPILL! mistake.

The region to which the UNIQUE function’s dynamic result set wants to be propagated is blocked.

Clear the cells where the result is trying to leak, then try again. On the other hand, if you type the formula in a formatted Excel table cell, convert the table to a regular range and try again.

See #REF! mistake.

The unique formula refers to an array in another workbook, but that workbook is closed.

Open the workbook containing the referenced array, and then try again.

An alert appears telling you that there is a problem with the formula.

You may have misspelled part of the formula.

When you click OK, the first part of the formula that is causing the problem is highlighted in the formula bar. Double-check this part of the formula, adjust it, and try again. Repeat this process until the formula is accepted. Alternatively, click Help for more support.


The UNIQUE function is not the only one in Excel that can be used to extract data. For example, the CHOOSECOLS and CHOSOEROWS functions allow you to extract specific columns or rows, the GETPIVOTDATA function allows you to extract specific information from a PivotTable, and with the DROP function, you can remove a specified number of rows or columns from the beginning or end of an array.

Leave a Comment