< Go Back

Extract unique items from a list

There are many ways to extract unique items or values from a list or range of cells. In this post, we will consider the formula method to extract unique items from a list.

Formula

The general formula for extracting unique values from a list or range of cells is:

=INDEX(list,MATCH(0,COUNTIF(exp_range,list),0))

It’s an array formula, we need to insert it in the cell by pressing Ctrl+Shift+Enter keys.

Explanation

Firstly, the formula includes INDEX, MATCH, and COUNTIF functions. We will go through each function in details below: 

  • INDEX function contains the list or range of cells that contain values with duplicates
  • MATCH function searches for an exact match of the value and returns its relative position in an array of
  • MATCH function include COUNTIF function and returns 1s where the items of the list are found in active expanding range, and return 0s where the items of the list are not present in active expanding range.

    Because we need to find unique items from a list, a search and match 0 as lookup value in an array of 1s and 0s. By default MATCH function returns the relative position of first matched value in an array and based on this relative position INDEX function returns the corresponding value in the list as a unique item.

Example

Secondly, we will go through a specific example for better understanding. Suppose we have a list of names that have duplicate values in range A2:A8 (list). Our goal is to extract unique items from a list. As the result, should be a list of names without duplication.

We will enter syntax in cell C2: 

=INDEX($A$2:$A$8,MATCH(0,COUNTIF($C$1:C1,$A$2:$A$8),0))

OR

=INDEX(List,MATCH(0,COUNTIF($C$1:C1,List),0))

Figure 1. Extracting Unique Values from a List

Where

  • List” is named range for A2:A8
  • $C$1:C1 is expanding the range to count the occurrence of items in list or range A2:A8 to return an array of 1s and 0s
  • If the formula is entered in cell C2, then expanding range must start from cell C1 as an absolute reference as $C$1 and next part of the range must be a relative reference as C1, like $C$1:C1, so it should expand when the formula is copied down to other rows.
  • An array format is a requirement in this formula

Explanation

The formula returns the relative row position of each unique item in a list using the following syntax:

=INDEX(list,relative_row_position)

Furthermore, the MATCH and COUNTIF function purpose are to assign the relative row positions of the cells to be retrieved. COUNTIF function is counting the number of times cells in the unique list appear in the original list, such as:

COUNTIF($C$1:C1,$A$2:$A$8)

OR

COUNTIF($C$1:C1,List

Applying COUNTIF function in cells must meet criteria

To find relative positions for matching result, MATCH function is a good choice. The function retrieve values by looking for items not present in expanding the range.

Finally, the positions given by the MATCH function are fed into INDEX function as relative_row_position, and INDEX returns the name at that relative position.

Non-array formula method

Additional, another way to extract unique items in Excel is using non-array formula. This is done using the LOOKUP function:

=LOOKUP(2,1/(COUNTIF($C$1:C1,list)=0),list)

The elements in the formula are almost like the INDEX MATCH formula. Excel LOOKUP function will handle array operation locally.

Our customers love us!
“The expert was absolutely amazing and stuck with me the whole way through. They were polite, patient, seemed to want to genuinely help me and provided a solution that I would never have managed otherwise. I could not be more thankful for their support and solution. Thank you!” - - Chris T, in California
This blog is one way to figure it out. A 20 minute chat session with an expert is a better way.Get step-by-step guidance on your question

Leave a Comment

avatar