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
Unique distinct values category
First, let me explain the difference between unique values and unique distinct values, it is important you know the difference […]
Question: I have two ranges or lists (List1 and List2) from where I would like to extract a unique distinct […]
This article shows how to extract unique distinct values based on a condition applied to an adjacent column using formulas. […]
The array formula in cell D3 extracts unique distinct values sorted A to Z, from column B to column D. […]
Anura asks: Is it possible to extend this by matching items that meet a criteria? I have a list of […]
Question: How do I extract a unique distinct list from three ranges or lists? The ranges are not necessarily adjacent […]
This article demonstrates formulas that extract unique distinct values and ignore blank empty cells. Table of contents Extract a unique […]
Question: I have cell values spanning over several columns and I want to create a unique list from that range. […]
Question: How do I create a unique distinct list where other columns meet two criteria using excel array formula? Answer: […]
This article demonstrates formulas that extract sorted unique distinct values from a cell range containing also blanks. Unique distinct values […]
This article demonstrates two formulas that extract distinct values from a filtered Excel Table, one formula for Excel 365 subscribers […]
Question: How do I create a unique distinct list where adjacent cell values contain a search string? AA102 CA AA103 […]
Filtering unique distinct text values and sorting them based on the sum of adjacent values can easily be done by […]
EEK asks: I am looking for the same formula on this page, but targeting a range of MxN (spanning multiple […]
This article demonstrates a formula that extracts unique distinct records/rows for a given month specified in cell C2, see the […]
Question: How to create unique distinct year and months from a long date listing (column A)? You can find the […]
Question: How do I create a unique distinct list from a column sorted A to Z using array formula? Array […]
This article demonstrates formulas that list unique distinct values if they contain a specified substring. Table of contents Extract unique […]
Table of Contents Filter unique distinct values based on a date range Filter unique distinct values based on a date […]
Question: I want a unique distinct list to be created from a column where an adjacent column has text cell […]
Functions in this article
More than 1300 Excel formulas
Excel formula categories
Excel categories
2 Responses to “Create a unique distinct list based on criteria”
Leave a Reply
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.
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