Ravindra BagaleCourses & study guides मराठी Track your progress

9. Dynamic Arrays

9.4 UNIQUE

UNIQUE list with totals with example — in 30 seconds

What: UNIQUE returns each value once. Put it inside SUMIFS and you get a small formula-based summary table.

Why: A city summary that grows by itself when a new city appears, without refreshing a pivot.

Tiny example: Ten rows have 6 different cities. The formula spills the cities with their totals.

First look at the data (before → after):

UNIQUE list with totals with example: before and after tables, fictional FreshGo Maharashtra data

Expected result — Spilled summary

City Total (₹)
Kolhapur 232
Nagpur 240
Nashik 360
Pune 544
Sambhaji Nagar 195
Solapur 1,299

About this data: Teaching sample for a fictional shop “Skyline Clinics”. Figures and names (e.g. Rohan Patil) are made up for this lesson on unique.

Before table and formula as text

Before — City and Amount in tblMini

City Amount
Pune 64
Nashik 270
Pune 110
Nagpur 240
Kolhapur 232
Pune 150
Solapur 1299
Sambhaji Nagar 195
Pune 220
Nashik 90

About this data: Demo table only — not real customer or company data. Built to practise unique.

Formula / click path

=UNIQUE(tblMini[City])
K2: =LET(c, SORT(UNIQUE(tblMini[City])), HSTACK(c, SUMIFS(tblMini[Amount], tblMini[City], c)))

Do it step by step:

  1. Start simple: type =UNIQUE(tblMini[City]) and press Enter.
  2. Wrap it in SORT: =SORT(UNIQUE(tblMini[City])).
  3. Now type the full formula in K2: =LET(c, SORT(UNIQUE(tblMini[City])), HSTACK(c, SUMIFS(tblMini[Amount], tblMini[City], c))).
  4. LET names the city list c, so it is calculated once and used twice.
  5. Check: the totals add up to 2,870.

=UNIQUE(array, [by_col], [exactly_once])

Need Formula Result (mini data)
Distinct cities =UNIQUE(tblMini[City]) 6 cities
Distinct cities sorted =SORT(UNIQUE(tblMini[City])) Kolhapur … Solapur
Count distinct =COUNTA(UNIQUE(tblMini[City])) 6
Cities appearing exactly once =UNIQUE(tblMini[City], , TRUE) Nagpur, Kolhapur, Solapur, Sambhaji Nagar
Distinct City–Platform pairs =UNIQUE(tblMini[[City]:[Platform]]) 7 pairs

About this data: Made-up rows so you can copy the pattern for unique. Currencies may use ₹, £, € or $.

Worked example – a self-updating summary.

=LET(c, SORT(UNIQUE(tblMini[City])),
     HSTACK(c, SUMIFS(tblMini[Amount], tblMini[City], c)))
City Sales
Kolhapur 232
Nagpur 240
Nashik 360
Pune 544
Sambhaji Nagar 195
Solapur 1,299

About this data: Fictional worksheet used in class. Safe to edit; nothing here is live production data.

Ravindra Bagale's Tip

UNIQUE counts "pune" and "Pune " (with a space) as different – many students see 8 cities instead of 6. Clean the data before using UNIQUE (Module 5). And "exactly_once = TRUE" means items that appear only once, not distinct – this can be asked in an interview.

Practice task

Build a self-updating city summary with UNIQUE + SUMIFS + COUNTIFS (sales and orders), sorted by sales descending.

Loading practice tasks...

  1. Different airlines (spill) (Easy): UNIQUE of D2:D8.
  2. Starting cities (spill) (Easy): UNIQUE of B2:B8.
  3. End cities (spill) (Easy): UNIQUE of C2:C8.
  4. How many airlines? (Easy): Count different airlines.
  5. Unique routes (spill) (Medium): UNIQUE of B2:C8.
  6. Sorted airlines (spill) (Medium): Sorted list of airlines.
  7. Airlines seen once (spill) (Medium): Airlines that appear exactly once in D2:D8.
  8. How many routes? (Medium): Count different routes in B2:C8.
  9. Cities going to Rome (spill) (Hard): Different starting cities for flights to Rome.
  10. Routes flown once (spill) (Hard): Routes in B2:C8 that appear exactly once.
  11. Passengers per airline (spill) (Hard): For each airline (no repeats) in D2 to D8, add up E2 to E8.

Quick revision cards

Three standalone cards. Each one explains the idea with its own example. Scan the QR to open this lesson.

Revision card 1: What is Unique?
Card 1: What is Unique? · Download PNG
Revision card 2: Tiny example — Unique
Card 2: Tiny example — Unique · Download PNG
Revision card 3: Checklist — Unique
Card 3: Checklist — Unique · Download PNG