Google Sheets UNIQUE IF: Filter Unique Values by Condition
In this article
Google Sheets does not have a built-in UNIQUEIF function, but you can get unique values that meet a condition by wrapping UNIQUE around FILTER: =UNIQUE(FILTER(range, condition_range, condition)). This returns only the distinct entries from range where the condition is true, in the order they first appear. For example, =UNIQUE(FILTER(A2:A100, B2:B100="Open")) lists each customer once from column A where column B says Open. You need a Google account and a sheet with at least two columns: one holding the values you want to deduplicate and one holding the criterion. No add-ons or scripts are required.
What You'll Need
- A Google account and access to Google Sheets (desktop browser or the Sheets mobile app).
- A spreadsheet with a column of values to deduplicate and a separate column containing the condition to test.
- Basic familiarity with cell references (e.g., A2:A100) and text criteria in quotes.
Step-by-Step
- Identify your ranges. Decide which column holds the values you want to list uniquely (the value range) and which column holds the condition (the criteria range). Both ranges must be the same height. For example, values in A2:A100 and status in B2:B100.
- Pick an empty cell where the result should start, such as D2. Make sure the cells below it are empty so the formula can spill without a #REF! error.
- Type the base formula. Enter
=UNIQUE(FILTER(A2:A100, B2:B100="Open"))and press Enter. Replace the ranges and the criterion with your own. The criterion can be text in quotes, a number without quotes, or a cell reference likeE2. - Check the result. You should see each distinct value from column A exactly once, but only for rows where column B equals "Open". The list spills downward automatically; do not drag-fill it.
- Use a cell reference for a dynamic criterion. If you want to change the filter without editing the formula, put the criterion in a cell (e.g., E2) and use
=UNIQUE(FILTER(A2:A100, B2:B100=E2)). Changing E2 updates the list instantly. - Add more conditions if needed. FILTER accepts multiple condition pairs separated by commas, and they are combined with AND logic:
=UNIQUE(FILTER(A2:A100, B2:B100="Open", C2:C100>0)). For OR logic, use a plus sign between conditions inside FILTER, or use REGEXMATCH for text patterns. - Handle blanks and errors. If no rows match, FILTER returns #N/A. Wrap it:
=IFERROR(UNIQUE(FILTER(A2:A100, B2:B100="Open")), "No matches"). To ignore blank values in the value range, add a condition such asA2:A100<>"". - Sort the unique list (optional). Wrap the whole thing in SORT:
=SORT(UNIQUE(FILTER(A2:A100, B2:B100="Open")))for ascending order, or add a second argument (1 for ascending, -1 for descending) and a column index if sorting by another column. - Test on mobile. The same formula works in the Sheets mobile app; type it into the formula bar. Spilled results display the same way, though editing long formulas on a phone is easier in landscape or with an external keyboard.
Menu labels and function behavior can differ slightly by Sheets version, device, and region, but UNIQUE and FILTER are standard functions available in all current versions.
Common Mistakes
- Mismatched range sizes. FILTER requires every range to have the same number of rows. A2:A100 with B2:B99 returns an error.
- Forgetting quotes around text criteria.
B2:B100=Openis treated as a named range or error; useB2:B100="Open". - Blocked spill range. If any cell in the spill area contains data, you get #REF!. Clear the cells below the formula.
- Using UNIQUE alone. UNIQUE by itself cannot filter by condition; it only removes duplicates from the whole range. Always pair it with FILTER for conditional uniqueness.
- Case sensitivity confusion. Text comparisons in FILTER are case-insensitive by default, so "open" matches "Open". Do not expect case-sensitive filtering without extra functions.
- Hard-coding criteria. Typing the criterion directly into the formula means editing the formula every time it changes. Use a cell reference instead.
Tips
- Use whole-column references like A:A and B:B only on small sheets; they slow recalculation on large data sets. Prefer bounded ranges such as A2:A5000.
- Combine with SORT and IFERROR in one formula to get a clean, sorted, error-free list:
=IFERROR(SORT(UNIQUE(FILTER(A2:A100, B2:B100="Open"))), "None"). - To count unique values matching a condition instead of listing them, use
=COUNTUNIQUE(FILTER(A2:A100, B2:B100="Open"))or=COUNTA(UNIQUE(FILTER(...))). - Name your ranges (Data > Named ranges) so formulas read more clearly, e.g.,
=UNIQUE(FILTER(Customers, Status="Open")). - If you need unique values across two columns combined, use
=UNIQUE({A2:A100; B2:B100})to stack them first, then filter as needed.
Troubleshooting
If you see #N/A, no rows matched your condition. Check spelling, extra spaces, and whether the criterion cell is blank. If you see #REF!, the spill range is blocked; clear the cells below the formula. If you see #VALUE!, one of your ranges has a different height than the others. If the list includes duplicates, confirm you wrapped FILTER inside UNIQUE and not the other way around. If the formula returns only the first value, the sheet may be in a mode that blocks array formulas, or you may have entered it as a single-cell formula in an older context; re-enter it in an empty cell and press Enter. If results do not update after changing the criterion cell, check that the formula references that cell and that automatic calculation is on (File > Settings > Calculation). As a last resort, copy the formula to a new sheet to rule out conflicting data or formatting.
Frequently Asked Questions
Is there a UNIQUEIF function in Google Sheets?
No. The correct pattern is UNIQUE(FILTER(range, condition_range, condition)), which produces unique values that meet the condition.
Can I use multiple conditions with UNIQUE and FILTER?
Yes. Add more condition_range, condition pairs inside FILTER; they are combined with AND logic. For OR logic, use a plus sign between conditions or REGEXMATCH.
Why does my formula return #N/A?
FILTER returns #N/A when no rows match. Wrap the formula in IFERROR to show a friendly message, and double-check the criterion text and range sizes.
Does UNIQUE(FILTER(...)) work on the mobile app?
Yes. The same functions are available in the Google Sheets mobile app for iPhone and Android; type the formula into the formula bar.
How do I ignore blanks in the unique list?
Add a condition such as A2:A100<>"" inside FILTER so blank cells are excluded before UNIQUE removes duplicates.
Can I sort the unique filtered list?
Yes. Wrap the whole expression in SORT: =SORT(UNIQUE(FILTER(...))). Add 1 for ascending or -1 for descending as the second argument.