Unique List with Counts

Excel Formulas › Dynamic Arrays

365 / 2021UNIQUE

Build a distinct list and how often each item appears — the formula version of a quick frequency table. UNIQUE spills the distinct values; COUNTIF tallies each one.


Quick formula: distinct items with their counts:
=HSTACK(UNIQUE(A2:A100), COUNTIF(A2:A100, UNIQUE(A2:A100)))
UNIQUE spills the distinct values; COUNTIF counts each against the full list; HSTACK puts them side by side.

Functions used (tap for the full reference guide):

The example

Distinct regions and how many times each occurs.

AB
1RegionCount
2East3
3West2

The formula

Distinct values beside their counts:

=HSTACK(UNIQUE(A2:A100), COUNTIF(A2:A100, UNIQUE(A2:A100))) // a live frequency table

How it works

Two spilling functions, combined:

  1. UNIQUE(range) spills the distinct values.
  2. COUNTIF(range, UNIQUE(range)) counts each distinct value against the full list — it spills a matching column of counts.
  3. HSTACK places the values and counts side by side as a two-column table.
  4. Sort it by count with SORTBY(…, counts, -1) to rank the most common first.

Or just use GROUPBY: =GROUPBY(Region, Region, COUNTA) produces the same distinct-with-count table in 2024 Excel. The UNIQUE+COUNTIF combo works in any 365/2021 build and is easy to sort or filter.

Try it: interactive demo

Live demo

Items (one per line) → distinct + counts.

Variations

Sort by count

Most common first:

=SORTBY(uniques, counts, -1)

GROUPBY (2024)

One function:

=GROUPBY(Region, Region, COUNTA)

Distinct count only

How many uniques:

=COUNTA(UNIQUE(range))

Pitfalls & errors

HSTACK is 365. If unavailable, put UNIQUE in one column and COUNTIF beside it manually.

Blanks become an item. UNIQUE includes a blank as a distinct value; filter it out if unwanted.

Spill room. Both functions spill — keep neighboring cells clear.

Practice workbook

📊
Download the free Unique List with Counts practice workbook
UNIQUE+COUNTIF frequency table (formula text + result) with sort, GROUPBY, and distinct-count variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I make a unique list with counts in Excel?
Combine UNIQUE and COUNTIF: =HSTACK(UNIQUE(range), COUNTIF(range, UNIQUE(range))) spills a live distinct-with-count table. Requires Excel 365/2021.
How do I sort the list by frequency?
Wrap with SORTBY on the counts: =SORTBY(UNIQUE(range), COUNTIF(range, UNIQUE(range)), -1) ranks the most common first.
Is there a one-function version?
In Excel 365 (2024+), =GROUPBY(Region, Region, COUNTA) produces the same distinct-with-count table.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Count unique values · Unique sorted list · GROUPBY

Function references: UNIQUE · COUNTIF