Table of contents

  1. Filter unique distinct row records
  2. Filter unique distinct row records but not blanks
  3. Filter unique distinct row records that does not begin with *string*
  4. Filter unique distinct row records that begins with *string*
  5. Filter unique distinct records [Pivot table]


Question: How do I extract unique distinct row records from this list?

Answer:

First, let me explain unique distinct records. A record is an entire row in the table, in this example. The picture below displays a small table in column B and C containing a duplicate record. The table in column E and F contains only unique distinct records.

In other words, unique distinct records are all records but duplicate records are removed.

Second, if you have a large data set, I highly recommend using a pivot table to extract unique distinct records. A Pivot table is incredibly fast and is also easy to quickly setup and manage.

Third, this post shows you how to construct an array formula that extracts unique distinct records.

Cell range A3:D26 contains the original list, cell range F3:I16 contains the filtered list.

Array formula in cell F3:

=INDEX($A$3:$D$26, MATCH(0, COUNTIFS($F$2:$F2, $A$3:$A$26, $G$2:$G2, $B$3:$B$26, $H$2:$H2, $C$3:$C$26, $I$2:$I2, $D$3:$D$26), 0), COLUMN(A1))

How to enter an array formula

  1. Select cell F3
  2. Type above formula in cell or formula bar
  3. Press and hold CTRL + SHIFT simultaneously
  4. Press Enter once

If you did the steps above correctly, the formula has now a beginning and ending curly bracket, like this {=array_formula}
Don't enter these characters yourself, they appear automatically if you did this right.

How to copy formula

Copy cell F3 and paste it to cells to the right, as far as needed. Then copy cells and paste them down, as far as needed.

Explaining array formula in cell F3

You can easily follow along while I go through this array formula, go to tab "Formulas" on the ribbon. Select cell F3 then click "Evaluate Formula" button. Click "Evaluate" button to move to next step.

Step 1 - Identify rows with unique records

INDEX($A$3:$D$26, MATCH(0, COUNTIFS($F$2:$F2, $A$3:$A$26, $G$2:$G2, $B$3:$B$26, $H$2:$H2, $C$3:$C$26, $I$2:$I2, $D$3:$D$26), 0), COLUMN(A1))

COUNTIFS function counts the number of cells specified by a given set of conditions or criteria

COUNTIFS($F$2:$F2, $A$3:$A$26, $G$2:$G2, $B$3:$B$26, $H$2:$H2, $C$3:$C$26, $I$2:$I2, $D$3:$D$26)

becomes

COUNTIFS($A$28:$A28, {"Sample0"; "Sample0"; "Sample1"; "Sample0"; "Sample0"; "Sample1"; "Sample1"; "Sample0"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample0"; "Sample1"; "Sample0"; "Sample1"; "Sample0"; "Sample0"; "Sample1"}, $B$28:$B28, {"B";"B";"A";"A";"B";"B"; "B";"A";"A";"A";"A";"A";"B";"A";"B"; "B";"A";"A";"B";"B";"A";"A";"A";"A"}, $C$28:$C28, {11; 11; 11; 10; 10; 10; 11; 11; 10; 11; 11; 10; 11; 10; 11; 11; 10; 11; 11; 10; 10; 10; 10; 11}, $D$28:$D28, {"AA111"; "AA110"; "AA111"; "AA111"; "AA110"; "AA111"; "AA111"; "AA110"; "AA110"; "AA110"; "AA111"; "AA110"; "AA110"; "AA111"; "AA111"; "AA111"; "AA110"; "AA110"; "AA110"; "AA111"; "AA110"; "AA110"; "AA110"; "AA110"})

becomes

COUNTIFS("Sample", {"Sample0"; "Sample0"; "Sample1"; "Sample0"; "Sample0"; "Sample1"; "Sample1"; "Sample0"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample1"; "Sample0"; "Sample1"; "Sample0"; "Sample1"; "Sample0"; "Sample0"; "Sample1"}, "Group", {"B";"B";"A";"A";"B";"B"; "B";"A";"A";"A";"A";"A";"B";"A";"B"; "B";"A";"A";"B";"B";"A";"A";"A";"A"}, "Number", {11; 11; 11; 10; 10; 10; 11; 11; 10; 11; 11; 10; 11; 10; 11; 11; 10; 11; 11; 10; 10; 10; 10; 11}, "Category", {"AA111"; "AA110"; "AA111"; "AA111"; "AA110"; "AA111"; "AA111"; "AA110"; "AA110"; "AA110"; "AA111"; "AA110"; "AA110"; "AA111"; "AA111"; "AA111"; "AA110"; "AA110"; "AA110"; "AA111"; "AA110"; "AA110"; "AA110"; "AA110"})

and returns

{0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0}

Step 2 - Find relative position of  a unique record

The MATCH function returns the relative position of an item in an array that matches a specified value

MATCH(0, COUNTIFS($F$2:$F2, $A$3:$A$26, $G$2:$G2, $B$3:$B$26, $H$2:$H2, $C$3:$C$26, $I$2:$I2, $D$3:$D$26), 0)

becomes

MATCH(0, {0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0}, 0)

and returns 1.

Step 3 - Return a value of the cell at the intersection of a particular row and column

INDEX function returns a value or reference of the cell at the intersection of a particular row and column, in a given range

=INDEX($A$3:$D$26, MATCH(0, COUNTIFS($F$2:$F2, $A$3:$A$26, $G$2:$G2, $B$3:$B$26, $H$2:$H2, $C$3:$C$26, $I$2:$I2, $D$3:$D$26), 0), COLUMN(A1))

becomes

=INDEX($A$3:$D$26, 1, COLUMN(A1))

becomes

=INDEX($A$3:$D$26, 1, 1)

becomes

=INDEX({"Sample0", "B", 11, "AA111"; "Sample0", "B", 11, "AA110"; "Sample1", "A", 11, "AA111"; "Sample0", "A", 10, "AA111"; "Sample0", "B", 10, "AA110"; "Sample1", "B", 10, "AA111"; "Sample1", "B", 11, "AA111"; "Sample0", "A", 11, "AA110"; "Sample1", "A", 10, "AA110"; "Sample1", "A", 11, "AA110"; "Sample1", "A", 11, "AA111"; "Sample1", "A", 10, "AA110"; "Sample1", "B", 11, "AA110"; "Sample1", "A", 10, "AA111"; "Sample1", "B", 11, "AA111"; "Sample1", "B", 11, "AA111"; "Sample1", "A", 10, "AA110"; "Sample0", "A", 11, "AA110"; "Sample1", "B", 11, "AA110"; "Sample0", "B", 10, "AA111"; "Sample1", "A", 10, "AA110"; "Sample0", "A", 10, "AA110"; "Sample0", "A", 10, "AA110"; "Sample1", "A", 11, "AA110"}, 1, 1)

and returns Sample0 in cell F3.

Download excel *.xlsx file

The workbook contains all five examples on five different worksheets.
Filter unique distinct records.xlsx

(Excel 2007 Workbook *.xlsx)

Related articles

5 easy ways to extract unique distinct values

Update: 30 Aug, 2017h You have quite a few options to choose from if you are looking for a way […]

How to remove blank rows

The image below shows you a data table in column A:D. Unfortunately it has some blank rows, however the formula below takes easily care of this issue.

Array formula in cell F3:

=INDEX($A$2:$D$26, MATCH(0, IF(($A$2:$A$26<>"")+($B$2:$B$26<>"")+($C$2:$C$26<>"")+($D$2:$D$26<>""), COUNTIFS($F$2:$F2, $A$2:$A$26, $G$2:$G2, $B$2:$B$26, $H$2:$H2, $C$2:$C$26, $I$2:$I2, $D$2:$D$26), 1), 0), COLUMN(A1))

Filter unique distinct row records that does not begin with *string*

This example lets you specify a string and a record is shown in cell range A30:D36 if it does NOT match the beginning characters in column A and it is NOT a DUPLICATE record.

Array formula in cell A30:

=INDEX($A$2:$D$26, MATCH(0, COUNTIFS($A$29:$A29, $A$2:$A$26, $B$29:$B29, $B$2:$B$26, $C$29:$C29, $C$2:$C$26, $D$29:$D29, $D$2:$D$26)+IFERROR(SEARCH($G$29, $A$2:$A$26)=1, 0)+0, 0), COLUMN(A1))

 

Filter unique distinct row records that begins with *string*

If you are looking for records that begin with *string*, see this formula. Note that the formula looks for values in col A that begins with a specific text string.

Array formula in cell A30:

=INDEX($A$2:$D$26, MATCH(0, COUNTIFS($A$29:$A29, $A$2:$A$26, $B$29:$B29, $B$2:$B$26, $C$29:$C29, $C$2:$C$26)+IFERROR(NOT(SEARCH($G$29, $A$2:$A$26)=1), 1)+0, 0), COLUMN(A1))

Download excel *.xlsx file

Filter unique distinct records.xlsx
(Excel 2007 Workbook *.xlsx)

Related articles

Filter unique distinct values using “contain” condition of a column in excel

Table of contents Filter unique distinct values using a "contain" condition Filter unique distinct values using a "contain" condition (Advanced […]

Functions used in this formula:

MATCH(lookup_value,lookup_array, [match_type])
Returns the relative position of an item in an array that matches a specified value

INDEX(array,row_num,[column_num])
Returns a value or reference of the cell at the intersection of a particular row and column, in a given range

COUNTIFS(criteria_range1,criteria1, criteria_range2, criteria2...)
Counts the number of cells specified by a given set of conditions or criteria

SEARCH(find_text,within_text, [start_num])
Returns the number of the character at which a specific character or text string is found reading left to right (not case-sensitive)