FILTER, UNIQUE and SORT: an Excel interview question
List each customer once, A to Z, for the region someone picks, in one formula that updates itself. The dynamic-array answer interviewers look for, and a sheet that grades yours.
UNIQUE returns each different value in a range once, as a list that spills down the sheet and updates when the data changes.
Available in Excel for Microsoft 365, Excel 2021 and later, and Excel for the web=UNIQUE(array, [by_col], [exactly_once])| Argument | Required | What it means |
|---|---|---|
array | Yes | The range to take the values from. |
by_col | No | TRUE to compare columns instead of rows. Leave it out for a normal list. |
exactly_once | No | TRUE to return only values that appear exactly once. |
Five rows, three different regions. The list spills from E2.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Rep | Region | Regions | ||
| 2 | Ana | East | East | ||
| 3 | Ben | West | West | ||
| 4 | Cara | East | North | ||
| 5 | Dan | North | |||
| 6 | Eli | East |
=UNIQUE(B2:B6) → EastCOUNTA counts the items UNIQUE returns: 3 regions.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Rep | Region | Regions | ||
| 2 | Ana | East | 3 | ||
| 3 | Ben | West | |||
| 4 | Cara | East | |||
| 5 | Dan | North | |||
| 6 | Eli | East |
=COUNTA(UNIQUE(B2:B6)) → 3Wrap it in SORT: =SORT(UNIQUE(B2:B6)).
No. "east" and "East" count as the same value.
Worked problems with practice sheets.
List each customer once, A to Z, for the region someone picks, in one formula that updates itself. The dynamic-array answer interviewers look for, and a sheet that grades yours.
#SPILL! means a formula's result needs more cells than are free. Here's how to find what's in the way, the other causes of #SPILL!, and how to fix each one.
Practise UNIQUE and the functions around it in a live grid that grades your result and explains your mistakes.
Runs in your browser · Graded on your result · No install