ShareYourGroupShareYourGroupGoogle Sheets

Only in Sheets

UNIQUE and COUNTUNIQUE functions in Google Sheets

UNIQUE returns each different value in a range once; COUNTUNIQUE counts how many different values there are.

A column of real data repeats itself: the same customers, cities and products again and again. UNIQUE reduces it to one of each. COUNTUNIQUE answers "how many different ones?" without making the list.

Syntax

=UNIQUE(range, [by_column], [exactly_once])
=COUNTUNIQUE(value1, [value2], ...)
ArgumentWhat it is
rangeThe range to take values from.
by_columnTRUE to compare columns. Leave it out, or FALSE, to compare rows.
exactly_onceTRUE to return only the values that appear exactly once.

Examples

Sample sheet: Twelve sales made by four salespeople in three regions.
ABCDEF
1DateSalespersonRegionProductUnitsAmount
205-Jan-2026AshaNorthNotebook201200
312-Jan-2026RaviSouthPen50500
420-Jan-2026MeenaNorthBag43000
502-Feb-2026AshaEastPen30300
614-Feb-2026KabirSouthNotebook15900
728-Feb-2026RaviNorthBag21500
803-Mar-2026MeenaEastNotebook402400
915-Mar-2026AshaNorthBag32250
1022-Mar-2026KabirSouthPen60600
1101-Apr-2026RaviEastNotebook251500
1218-Apr-2026MeenaNorthPen80800
1306-May-2026AshaSouthBag53750

How UNIQUE works

UNIQUE reads down the range and returns each value the first time it appears. The result spills into the cells below. The order is the order of first appearance. Wrap it in SORT for an alphabetical list.

The list is live. A new value added to the data appears in it at once. Compare that with Data, Data clean-up, Remove duplicates, which deletes rows from the data itself and must be run again each time.

Several columns

Given two or more columns, UNIQUE compares whole rows and returns each different combination. =UNIQUE(C2:D13) lists every pairing of region and product that occurs.

Values that appear only once

Set the third argument to TRUE and UNIQUE returns only the values that have no duplicate at all. =UNIQUE(A2:A100, FALSE, TRUE) finds one-time customers, or the entries in a list that were not repeated.

COUNTUNIQUE

COUNTUNIQUE returns the number of different values in one step. It ignores empty cells. In Excel, the same count needs COUNTA(UNIQUE(...)), so this is a small convenience that Sheets has to itself.

To count different values among the rows that meet a condition, use COUNTUNIQUEIFS: =COUNTUNIQUEIFS(B2:B13, C2:C13, "North") is the number of different salespeople who sold in the North.

A summary with two formulas

  1. In H2: =UNIQUE(B2:B13) lists the salespeople.
  2. In I2: =ARRAYFORMULA(SUMIF(B2:B13, H2:H5, F2:F13)) puts each one's total beside the name.

For a summary that grows by itself as names are added, QUERY with group by does both steps in one formula.

A drop-down list from the data

Put =SORT(UNIQUE(D2:D)) in a spare column. Then use Data, Data validation with "Dropdown (from a range)" pointing at that column. The choices offered always match the values in use.

How values are compared

Common mistakes

In Excel

Excel 2021 and Microsoft 365 have UNIQUE with the same three arguments. In Excel, UNIQUE treats capital and small letters as the same. Excel has no COUNTUNIQUE or COUNTUNIQUEIFS.

Related functions

The results on this page were worked out by us from the sample sheet; they were not produced by a script running Google Sheets. If Sheets shows you something different, please tell us.

This is an independent help site. It is not connected with or approved by Google. Google Sheets is a trademark of Google LLC, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.