## Create a unique distinct list based on criteria

The regular formula in cell E6 extracts unique distinct values from column B based on the corresponding number in column C, the min value is in cell F2 and the Max value is in cell F3.

Formula in cell E6:

### Explaining formula in cell E6

#### Step 1 - Prevent duplicate values

The COUNTIF function counts values based on a condition, in this case, multiple conditions. The first argument has an expanding cell range that grows when the cell is copied to cells below. This allows the formula to count for previously shown values.

COUNTIF($E$5:E5, $B$3:$B$12)=0

becomes

COUNTIF("Unique distinct list",{"AA";"DD";"EE";"BB";"AA";"AA";"BB";"CC";"CC";"BB"})=0

becomes

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

and returns

{TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}.

#### Step 2 - Check which records meet criteria

The less than and greater than signs lets you create logical expressions. Each condition is checked against the values in column C.

($C$3:$C$12<=$F$3)*($C$3:$C$12>=$F$2)

becomes

{7;9;9;8;2;6;3;2;1;8}<=8)*({7;9;9;8;2;6;3;2;1;8}>=2)

becomes

({TRUE;FALSE;FALSE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE})*({TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;TRUE})

Both arguments must be TRUE, we must then multiply the arrays.

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

#### Step 3 - Multiply arrays

All criteria must be met.

(COUNTIF($E$5:E5,$B$3:$B$12)=0)*($C$3:$C$12<=$F$3)*($C$3:$C$12>=$F$2)

becomes

{TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}*{1;0;0;1;1;1;1;1;0;1}

and returns

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

#### Step 4 - Divide 1 with array

The LOOKUP function ignores errors, if we divide something with 0 (zero) we get #DIV/0! error.

1/((COUNTIF($E$5:E5,$B$3:$B$12)=0)*($C$3:$C$12<=$F$3)*($C$3:$C$12>=$F$2))

becomes

1/{1;0;0;1;1;1;1;1;0;1}

and returns

{1;#DIV/0!;#DIV/0!;1;1;1;1;1;#DIV/0!;1}.

#### Step 5 - Return value

LOOKUP(2, 1/((COUNTIF($E$5:E5, $B$3:$B$12)=0)*($C$3:$C$12<=$F$3)*($C$3:$C$12>=$F$2)), $B$3:$B$12)

becomes

LOOKUP(2, {1;#DIV/0!;#DIV/0!;1;1;1;1;1;#DIV/0!;1}, $B$3:$B$12)

becomes

LOOKUP(2, {1;#DIV/0!;#DIV/0!;1;1;1;1;1;#DIV/0!;1}, {"AA";"DD";"EE";"BB";"AA";"AA";"BB";"CC";"CC";"BB"})

### Get Excel *.xlsx file

5 easy ways to extract Unique Distinct Values

First, let me explain the difference between unique values and unique distinct values, it is important you know the difference […]

Extract a unique distinct list from two columns

Question: I have two ranges or lists (List1 and List2) from where I would like to extract a unique distinct […]

Vlookup – Return multiple unique distinct values

Ahmed Ali asks: How to return multiple values using vlookup in excel and removing duplicates? I have tried the formula […]

Extract a unique distinct list sorted from A to Z

The array formula in cell D3 extracts unique distinct values sorted A to Z, from column B to column D. […]

Extract a unique distinct list and sum amounts based on a condition

Anura asks: Is it possible to extend this by matching items that meet a criteria? I have a list of […]

Extract a unique distinct list from three columns

Question: How do I extract a unique distinct list from three ranges or lists? The ranges are not necessarily adjacent […]

Extract a unique distinct list and ignore blanks

This article demonstrates formulas that extract unique distinct values and ignore blank empty cells. Table of contents Extract a unique […]

Extract unique distinct values from a multi-column cell range

Question: I have cell values spanning over several columns and I want to create a unique list from that range. […]

Extract unique distinct values A to Z from a range and ignore blanks

This is an answer to a question in this blog post: Extract a unique distinct list sorted from A-Z from […]

How to create a unique distinct list based on two conditions

Question: How do I create a unique distinct list where other columns meet two criteria using excel array formula? Answer: […]

### 2 Responses to “Create a unique distinct list based on criteria”

### Leave a Reply to harry

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form

Hi,

I'm trying to create a unique distinct list from a column where an adjacent column has a specific name. I've looked at your guide where an adjacent column meets criteria, but this doesn't seem to help, I've simply replaced the

=INDEX(List_category, MATCH(0, COUNTIF($F$4:F4, List_category)+(List_value$E$2), 0))

With

=INDEX(List_category, MATCH(0, COUNTIF($F$4:F4, List_category)+(List_value="name"), 0))

where the name is actually a link to a cell with the name I'm looking for (format: $A$1)

This hasn't seemed to work for some reason, so I'm a bit stumped.

Could you offer any advice?

Thanks

Harry