How to Get Unique Values with Criteria in Excel
Learn how to extract unique values that meet specific criteria in Excel using FILTER, UNIQUE, and SORT. A practical, step-by-step guide for aspiring and professional Excel users seeking efficient data cleaning and analysis.
You will learn how to extract unique values from a dataset that meets specific criteria using Excel. We'll combine FILTER with UNIQUE to return distinct results, discuss alternatives for older versions, and provide practical examples with real-world data. Make sure you have Excel 365 or later, a structured data table, and clear criteria to filter by.
What unique values with criteria means
When you work with datasets in Excel, you often need to pull out only the items that matter and, among those, keep only the distinct values. The concept of unique excel with criteria refers to combining filtering logic with deduplication so the final list contains each item once, and only if it meets your conditions. According to XLS Library, applying dynamic array functions like FILTER and UNIQUE makes this both efficient and repeatable. This approach supports cleaner dashboards, more reliable reports, and faster data-driven decisions. In this guide, we’ll cover the core formulas, practical examples, and best practices to apply immediately in your workflows.
The approach starts with a clear data structure. Place your data in a table or a clearly defined range, ensure headers are consistent, and decide which column contains the values to deduplicate and which columns define the criteria. By focusing on both deduplication and criteria at the data source, you reduce downstream manual work and minimize errors in reporting.
Core formulas: FILTER, UNIQUE, and SORT
Excel’s dynamic array era introduced three powerful functions for this task: FILTER, UNIQUE, and SORT. FILTER lets you pull rows that satisfy one or more conditions. UNIQUE removes duplicate values from a single axis or a spill range. SORT orders the resulting values for easier consumption. When combined, these functions deliver a compact, resilient solution that adapts as data changes. Practical patterns below show how to structure the formulas, what to watch out for, and how to handle common edge cases.
Key patterns include:
- Single criterion: Use FILTER to limit which rows contribute values to the deduplication step.
- Multiple criteria: Multiply boolean arrays to enforce all conditions must be true.
- Readable output: Wrap with SORT to present results in a consistent order.
Common formulas you’ll see:
- Single criterion:
=UNIQUE(FILTER(A2:A100, B2:B100="Active"))
- Multiple criteria:
=UNIQUE(FILTER(A2:A100, (B2:B100="Active")*(C2:C100>100)))
- Sorted results:
=SORT(UNIQUE(FILTER(A2:A100, (B2:B100="Active")*(C2:C100>100))))
Handling multiple criteria and text matching
Real-world datasets often require text matching and case-insensitive comparisons. You can normalize text with LOWER or UPPER before comparing, and you can use wildcard-like matching with SEARCH when needed. The following patterns illustrate robust handling of common text-based criteria while keeping the list unique:
- Case-insensitive match and numeric criteria:
=UNIQUE(FILTER(A2:A100, (LOWER(B2:B100)="active")*(C2:C100>100)))
- Partial text match with numeric filter:
=UNIQUE(FILTER(A2:A100, (ISNUMBER(SEARCH("lab", LOWER(B2:B100))))*(C2:C100>50)))
If your data contains blanks, consider extending the criteria to exclude blanks, for example by adding A2:A100<>"" as an extra condition.
Practical example: customer IDs with Active status and order total over 100
Suppose you have a customer dataset with CustomerID in column A, Status in column B, and OrderTotal in column C. You want a list of unique CustomerIDs that are Active and have an OrderTotal greater than 100. The combined approach below uses FILTER to apply criteria and UNIQUE to deduplicate:
- Core formula:
=UNIQUE(FILTER(A2:A100, (B2:B100="Active")*(C2:C100>100)))
If you also want to exclude blanks from the result:
- Robust formula:
=UNIQUE(FILTER(A2:A100, (B2:B100="Active")*(C2:C100>100)*(A2:A100<>"")))
This pattern keeps the output compact and reduces post-processing steps in your dashboards and reports. Remember to verify that the data range expands as new rows are added and to convert the dataset into a formal Excel Table for automatic expansion.
Practical example 2: product codes by category and price range
Another common scenario is extracting a list of unique product codes that belong to a specific category and fall within a price range. Set ProductCode in column D, Category in column E, and Price in column F. To obtain unique ProductCodes for Electronics priced between 50 and 300, use:
- Formula:
=UNIQUE(FILTER(D2:D500, (E2:E500="Electronics")*(F2:F500>=50)*(F2:F500<=300)))
If you want the output to be sorted alphabetically, wrap the formula in SORT:
- Sorted output:
=SORT(UNIQUE(FILTER(D2:D500, (E2:E500="Electronics")*(F2:F500>=50)*(F2:F500<=300))))
These patterns show how criteria-driven deduplication can scale to multiple datasets without rewriting logic. As your data evolves, keep your assumptions explicit and test each criterion against a control sample to ensure correctness.
Troubleshooting and performance considerations
While FILTER and UNIQUE are powerful, several practical considerations help maintain performance on large datasets. Structuring data as a table (Ctrl-T) ensures references expand automatically, which reduces formula maintenance. When data grows, spill ranges may consume more memory; in such cases, consider filtering first in Power Query, then applying UNIQUE on the result. If you encounter errors, check for non-numeric values in numeric criteria columns and confirm that comparison operators align with the data type. In mixed environments (Windows vs Mac), verify that the functions used are supported by your Excel version and update if necessary.
Edge cases include:
- Blanks in the criteria column leading to unexpected results
- Text that appears numeric (e.g., "100" as text) causing misinterpretation
- Date criteria requiring correct date formats and consistent time components
Workarounds include data sanitization steps, using VALUE or DATEVALUE where appropriate, and wrapping formulas with IFERROR to present clean outputs in dashboards.
Validation, testing, and best practices
Validation is essential to ensure that the deduplicated results truly reflect the intended criteria. Start with a smaller sample where you know the expected outcomes, then scale up. Compare the output against a manual list or a PivotTable to confirm accuracy. Best practices include using a named range or a structured table reference (e.g., Table1[CustomerID]) to make formulas robust to edits and additions. Always document the exact criteria in a separate sheet or the formula comments so colleagues can replicate or modify the approach. Finally, consider version control for complex sheets to track changes over time.
Advanced techniques and best practices
Beyond the basics, you can enhance workflows with a few advanced approaches. One method is using named ranges to simplify long formulas and improve readability. You can also combine these patterns with INDEX/MATCH or XLOOKUP to fetch related attributes for each unique item, enabling richer downstream analyses. For teams, building a small, reusable template that accepts inputs (data range, criterion values) reduces repetitive work and minimizes mistakes. If you often perform identical queries, consider creating a dynamic named range that automatically adjusts as data grows, and document your template’s assumptions. The goal is to make your unique-with-criteria workflow repeatable, auditable, and scalable for future datasets.
The XLS Library conclusion and practical takeaway
The XLS Library team recommends adopting a disciplined approach to unique values with criteria by standardizing the use of FILTER, UNIQUE, and SORT in modern Excel. When your data has clear headers, well-defined criteria, and a stable structure, you can produce reliable, deduplicated lists with minimal effort. Building templates that encapsulate the formulas, along with inline comments and usage notes, helps teams onboard quickly and reduces errors. By following these patterns, you can unlock consistent data summaries that power dashboards, reports, and data-driven decisions across the organization.
Tools & Materials
- Excel 365 or later(Dynamic arrays are essential; ensure access to FILTER, UNIQUE, and SORT)
- Sample dataset (Excel workbook or CSV)(Organize data in a table with clear headers; designate columns for values and criteria)
- Optional: Power Query(Helpful for data import/initial cleaning before applying formulas)
- Table formatting(Convert data to a formal table (Ctrl-T) for auto-expansion and structured references)
Steps
Estimated time: 45-60 minutes
- 1
Prepare and structure your data
Convert your data range to a formal Excel Table and identify which column contains the values to deduplicate and which columns define the criteria. This setup ensures formulas spill correctly and remain readable as data grows.
Tip: Use a table name (e.g., DataTbl) for robust references. - 2
Filter by a single criterion
Create a filtered list that only includes rows meeting one condition. Use FILTER to return the subset that will feed the deduplication step.
Tip: Example: `=FILTER(DataTbl[CustomerID], DataTbl[Status]="Active")` - 3
Extract unique values from filtered data
Wrap the filtered results with UNIQUE to remove duplicates while preserving the order. This yields a clean list of distinct values that meet the criterion.
Tip: Combine with SORT for readable ordering. - 4
Add a second criterion (AND logic)
If you need multiple conditions, multiply the boolean arrays. This enforces all criteria must be true for each row to be included.
Tip: Avoid mixing text and numbers without normalization. - 5
Sort the final results
Use SORT to present the unique values in a stable, easy-to-scan order, aiding dashboards and user consumption.
Tip: Ascending order is common for IDs or codes. - 6
Handle blanks and data type issues
Add checks to exclude blanks and harmonize data types (text vs number) to prevent unexpected results.
Tip: Wrap with IFERROR to present clean output in dashboards. - 7
Validate results with a quick cross-check
Spot-check samples against a manual list or a PivotTable to confirm accuracy before sharing.
Tip: Document the criteria used for future audits. - 8
Package as a reusable template
Create a small workbook that accepts data range and criteria values as inputs, and returns a deduplicated, filtered list.
Tip: Use named cells for input values to simplify reuse.
People Also Ask
Can I use UNIQUE with criteria in Excel versions prior to 365?
FILTER and UNIQUE are part of dynamic arrays in Excel 365 and later. For older versions, consider using legacy array formulas with INDEX, SMALL, and IF, or Power Query as an alternative.
In older Excel versions, use legacy methods like INDEX and SMALL to emulate the behavior, or upgrade to a version that supports dynamic arrays.
What happens if there are blanks in the data?
If blanks appear in the value column, they may appear in the result. Add an extra criterion to exclude blanks, such as A2:A100<>"".
Exclude blanks by adding a condition like A2:A100<>"" to the FILTER criteria.
How can I ensure results update automatically when data changes?
Use a Table reference (e.g., DataTbl[CustomerID]) so the formula spills as the table grows. This keeps outputs current without manual edits.
Make your data a table so formulas expand automatically as new rows are added.
Why should I SORT the unique results?
Sorting improves readability and makes it easier to compare outputs across reports and dashboards.
Sorting makes the result easier to scan and use in analyses.
Can I apply more than two criteria at once?
Yes. Add more conditions inside the FILTER, combining with logical operations. Use parentheses to group criteria correctly.
You can stack multiple criteria by adding more conditions inside FILTER.
Watch Video
The Essentials
- Define clear criteria before formulas.
- Use FILTER with UNIQUE for dynamic deduplication.
- Add SORT for readability and consistency.
- Validate results with samples and cross-checks.

