The monthly report problem
Every month, someone in almost every company gets the same request: show me revenue by category, by region, by month. The data is a long list of order lines, and the answer is a small summary table. Most people build it with a PivotTable, and that works well until the layout needs to match a template, a number has to be checked cell by cell, or someone forgets to press Refresh before the report goes out. This course is for analysts, controllers, sales operations and small-business owners who want summary reports that update themselves, sit exactly where they are needed and can be audited by anyone who clicks a cell.
The idea is simple: everything a PivotTable shows can be rebuilt with a handful of modern Excel formulas. In this first lesson you rebuild the part that everything else depends on, the row labels. That is the list of distinct categories (or regions, or products) down the left side of every summary. Get that list right with one live formula, and every number next to it can follow automatically.
We use the data of Brightwater Outdoor Co., a fictional outdoor-gear wholesaler with 20 order lines for the first quarter of 2026. The same data sits in the lab above, so you can try each formula as you read.
What a PivotTable really does
A PivotTable has four areas in its Fields pane. Rows gives you one line per distinct value of a field. Columns gives you one column per distinct value. Values fills the grid with a Sum, Count, Average or another summary. Filters limits the whole report to a subset, such as one sales channel. Strip away the drag-and-drop interface and each area is a small, well-defined calculation. That is why each one has a formula twin.
The Rows area is the foundation. Before Excel can sum revenue per category, it has to know which categories exist. A PivotTable finds them by scanning the field and listing each value once, sorted A→Z by default. In formula terms that is two functions: UNIQUE to remove duplicates and SORT to put the result in order.
UNIQUE and SORT, explained simply
=UNIQUE(C2:C21) looks at the 20 category cells and returns every value once, in the order in which it first appears. For Brightwater that is Tents (row 2), Footwear (row 3), Packs (row 4) and Apparel (row 5). The result is a dynamic array: you type the formula in one cell and Excel spills the four results into the cells below. If you add an order line with a new category to the source range, the list grows by itself.
=SORT(UNIQUE(C2:C21)) wraps the distinct list in SORT, which sorts it ascending by default. Now the list reads Apparel, Footwear, Packs, Tents, exactly like a PivotTable's default row order. SORT has optional arguments: the column to sort by, the order (1 for ascending, -1 for descending) and whether to sort by columns instead of rows. For a single column of labels the defaults are all you need.
#NAME?.Worked example: Brightwater Outdoor Co., Q1 2026
Here is the full source data from the lab, A1:F21. Each line is one order with its region, product category, sales channel, units and revenue. All names and numbers are fictional.
| Order | Region | Category | Channel | Units | Revenue |
|---|---|---|---|---|---|
| BW-1001 | North | Tents | Online | 4 | 1,560 |
| BW-1002 | West | Footwear | Retail | 12 | 1,380 |
| BW-1003 | South | Packs | Online | 9 | 1,035 |
| BW-1004 | North | Apparel | Retail | 20 | 1,100 |
| BW-1005 | East | Tents | Retail | 3 | 1,290 |
| BW-1006 | West | Packs | Online | 7 | 840 |
| BW-1007 | East | Apparel | Online | 15 | 795 |
| BW-1008 | South | Footwear | Retail | 10 | 1,240 |
| BW-1009 | North | Packs | Retail | 6 | 702 |
| BW-1010 | West | Tents | Online | 5 | 2,050 |
| BW-1011 | South | Apparel | Online | 18 | 936 |
| BW-1012 | East | Footwear | Online | 8 | 1,032 |
| BW-1013 | North | Footwear | Online | 11 | 1,353 |
| BW-1014 | West | Apparel | Retail | 22 | 1,166 |
| BW-1015 | South | Tents | Retail | 2 | 860 |
| BW-1016 | East | Packs | Retail | 10 | 1,150 |
| BW-1017 | North | Tents | Retail | 3 | 1,200 |
| BW-1018 | West | Footwear | Online | 9 | 1,107 |
| BW-1019 | East | Tents | Online | 4 | 1,680 |
| BW-1020 | South | Packs | Retail | 8 | 960 |
Step 1, the row labels. In H2 type =SORT(UNIQUE(C2:C21)). The formula spills into H2:H5 and returns Apparel, Footwear, Packs and Tents. H5, the last label, is Tents. That is the cell the Coach checks in the lab.
Step 2, the distinct count. A report often needs to know how many rows it will have, for example to size a chart or to check that no category is missing. In L2 type =ROWS(UNIQUE(C2:C21)), or refer to the spilled list directly with =ROWS(H2#). Both return 4. The # after H2 is the spill range operator: it always means "the whole result that spills from H2", however long it currently is. =ROWS(C2:C21) would return 20, the number of order lines, which is a common mix-up.
Step 3, two fields in Rows. When you drag Region and then Category into a PivotTable's Rows area, you get a two-level outline: each region, and under it the categories that occur in that region. The formula version is a two-column UNIQUE: =UNIQUE(B2:C21) returns every Region/Category combination that occurs in the data. To sort it by region first and then by category within each region, give SORT an array of sort columns: =SORT(UNIQUE(B2:C21),{1,2}). Brightwater sells all four categories in all four regions, so the list has 16 rows:
| Region (J) | Categories (K), sorted A→Z within the region | Rows |
|---|---|---|
| East | Apparel, Footwear, Packs, Tents | 4 |
| North | Apparel, Footwear, Packs, Tents | 4 |
| South | Apparel, Footwear, Packs, Tents | 4 |
| West | Apparel, Footwear, Packs, Tents | 4 |
East comes first alphabetically and fills J2:K5. North starts in row 6, so K6 is Apparel, the first category of North. If you sort only by the first column with =SORT(UNIQUE(B2:C21)), the regions are in order but the categories inside each region keep their order of first appearance. In this data North would then start with Tents, not Apparel. That is exactly the subtle difference a PivotTable hides from you, and a formula makes visible.
Where this leads. Once the labels exist, the values are one formula away. The table below is a preview of the next lesson: the row labels from H2#, an order count with COUNTIFS and the revenue with SUMIFS, both pointing at the spilled list so they grow and shrink with it.
| H (row labels) | Order lines=COUNTIFS(C2:C21,H2#) | Revenue=SUMIFS(F2:F21,C2:C21,H2#) | Share |
|---|---|---|---|
| Apparel | 4 | 3,997 | 17.1% |
| Footwear | 5 | 6,112 | 26.1% |
| Packs | 5 | 4,687 | 20.0% |
| Tents | 6 | 8,640 | 36.9% |
| Grand total | 20 | 23,436 | 100.0% |
How to build the row labels in Excel, step by step
- Click any cell in the data and press Ctrl+T (Insert > Table) if you want new order lines to be included automatically. Confirm that the table has headers.
- Leave at least one empty column between the data and your report, so the spilled results never collide with the source data. In the lab the report starts in column H.
- Click H1, type the header Category, then click H2 and type
=SORT(UNIQUE(C2:C21)). If you converted the data to a Table, Excel may write=SORT(UNIQUE(Table1[Category]))when you select the column; both work. - Press Enter. The list spills into H2:H5. A thin blue border appears around the spill range when you select any cell in it.
- Make sure the cells below H2 are empty. If anything is in the way, Excel shows
#SPILL!in H2. Clear the blocking cell and the list appears. - In L2 type
=ROWS(H2#)to count the labels. Type the#yourself, or select the whole spill range with the mouse and Excel inserts it for you. - For the two-level list, click J2 and type
=SORT(UNIQUE(B2:C21),{1,2}). The curly brackets create an array constant: sort by column 1, then by column 2. - Test it: change one category in the source, for example C21 from Packs to Stoves. A fifth label appears in H2:H6, L2 shows 5, and the two-level list gains a South/Stoves row. Press Ctrl+Z to undo.
=SORT(UNIQUE(C2:C21),,-1). The empty second argument keeps the default sort column, and -1 reverses the order.PivotTable or formulas: which should you use?
Both have their place. A PivotTable is unbeatable for quick exploration: drag a field, look, drag another. A formula report wins when the summary has a fixed layout, has to update without anyone remembering to refresh, or needs to be checked by an auditor or a manager who wants to see where a number comes from.
| PivotTable | Formula report | |
|---|---|---|
| Updates when data changes | Only after Refresh (Alt+F5, or Ctrl+Alt+F5 for all) | Instantly, like any formula |
| Layout | Fixed grid, limited formatting options | Any cell, any layout, mix with other formulas |
| Checking a number | Double-click to drill down | Click the cell and read the formula |
| Distinct count | Needs the Data Model | =ROWS(UNIQUE(C2:C21)) |
| Speed of building | Very fast, drag and drop | A few formulas, then reusable |
| Excel version | Every desktop version | Microsoft 365, Excel 2021 or later for UNIQUE/SORT |
If you want to compare the two yourself in desktop Excel: click a cell in the data, choose Insert > PivotTable, place it on a new sheet, and drag Category into Rows. Then drag Region above Category, and under Design > Report Layout choose Show in Tabular Form to see the two fields side by side, just like J:K. Newer Microsoft 365 versions also include the functions GROUPBY and PIVOTBY, which build a whole summary in one formula. They are useful to know about, but UNIQUE, SORT and SUMIFS work in more Excel versions and show every step clearly, which is why this course builds on them.

Common mistakes and how to spot them
- #SPILL! in the label cell. Something is in the cells the result wants to occupy, even a single space. Click the error, open the small warning menu and choose Select Obstructing Cells, then clear them.
- Unsorted labels.
=UNIQUE(C2:C21)alone keeps the order of first appearance. If your list starts with Tents instead of Apparel, wrap it in SORT. - Hidden duplicates. "Tents" and "Tents " (with a trailing space) are different values to UNIQUE, so you get two Tents rows. Look for labels that seem identical, and clean the source with TRIM, or use
=SORT(UNIQUE(TRIM(C2:C21))). - A 0 at the end of the list. If your range includes empty cells, UNIQUE returns one blank value that displays as 0. Exclude blanks with
=SORT(UNIQUE(FILTER(C2:C99,C2:C99<>""))). - Counting lines instead of labels.
=ROWS(C2:C21)returns 20. A distinct count needs=ROWS(UNIQUE(C2:C21))or=ROWS(H2#). - Sorting a two-column list by one column only.
=SORT(UNIQUE(B2:C21))sorts by region but leaves categories inside a region in their original order. Use{1,2}as the sort index. - Fixed ranges that stop too early. If new orders are added in row 22 and your formula says C2:C21, they are ignored. Use an Excel Table or a range with room to grow plus FILTER for blanks.
Quick reference: functions and shortcuts used
| Function / shortcut | What it does | Example |
|---|---|---|
UNIQUE(array, [by_col], [exactly_once]) | Returns each distinct value (or row) once, in order of first appearance. | =UNIQUE(C2:C21) |
SORT(array, [sort_index], [sort_order], [by_col]) | Sorts a range or array; sort_order 1 = ascending, -1 = descending. | =SORT(UNIQUE(B2:C21),{1,2}) |
ROWS(array) | Counts the rows of a range or array. | =ROWS(UNIQUE(C2:C21)) |
COUNTA(value) | Counts non-empty cells or array items. | =COUNTA(UNIQUE(C2:C21)) |
H2# | Spill range operator: refers to the whole spilled result of H2. | =ROWS(H2#) |
FILTER(array, include) | Keeps only rows that meet a condition, e.g. no blanks. | =UNIQUE(FILTER(C2:C99,C2:C99<>"")) |
Ctrl+T | Turns a data range into an Excel Table that grows with new rows. | Insert > Table |
Alt+F5 / Ctrl+Alt+F5 | Refreshes the selected PivotTable / all data connections (Windows). | PivotTable Analyze > Refresh |
Real-world uses
- Monthly management pack. A one-page summary of revenue by product line that sits in a fixed, branded layout and updates the moment the new month's data is pasted in, without anyone pressing Refresh.
- Sales territory review. A two-level Region/Customer list built with
SORT(UNIQUE(…),{1,2})becomes the backbone of a territory report, showing every customer under its region with their sales next to it. - Data quality checks. A quick
=SORT(UNIQUE(C:C))on a supplier or cost-centre column exposes misspellings and stray spaces before they split one total into two. - Dropdown lists that maintain themselves. A spilled UNIQUE list can be the source of a Data Validation dropdown (source
=$H$2#), so new categories appear in the dropdown automatically. - Dashboards and charts. Charts that point at spilled label and value ranges pick up new categories without editing the chart's data range by hand, as you will see in later lessons.
What you will build in the rest of this course
With the row labels in place, the remaining 19 labs rebuild every other part of a PivotTable with Brightwater's data, and each one is graded instantly so you know your formulas are right.
Values: SUMIFS over the Spilled Labels (H2#). You fill the Values column with one SUMIFS that follows the spilled labels, add a grand total, a calculated field (revenue per unit) and a version sorted largest first. This is the moment the report starts to look like a real PivotTable.
Cross-Tabs: Rows × Columns with UNIQUE, TRANSPOSE and One SUMIFS Grid. You build a revenue matrix with regions down and categories across, using a header formula, a single grid formula and row and column totals. One formula fills sixteen cells.
Show Values As: % of Grand Total, % of Row and % of Column. You turn the matrix into three percentage views and chart each region's category mix as a 100% stacked column chart, and learn which percentage answers which business question.
Count, Average, Max and Distinct Count: COUNTIFS, AVERAGEIFS, MAXIFS. You summarise orders per region four ways: number of orders, average order value, largest order and number of distinct customers, including the distinct count that a normal PivotTable cannot do without the Data Model.
Report Filters: Criteria Cells, (All) and a Drill-Down List. You add a Channel filter and a Region filter with an (All) option, then list the orders behind one number, just like double-clicking a value in a PivotTable.
Grouping Dates by Month and Quarter: EOMONTH and Text Keys. You roll half a year of order lines up to months and quarters with a helper key column and SUMIFS over the spilled keys, the formula version of a PivotTable's date grouping.
Mid-course project: A Subtotal Report, a Summary that Ignores It, and a Chart. You finish a printed subtotal report with SUBTOTAL, add a grand total that does not double count, rebuild the region summary with SUMIFS and chart it. You leave with a complete reporting pattern you can reuse on your own data.
Summary
A PivotTable's Rows area is just the distinct, sorted list of a field. =SORT(UNIQUE(C2:C21)) rebuilds it with one live formula, =ROWS(H2#) counts the labels, and =SORT(UNIQUE(B2:C21),{1,2}) creates a two-level Region/Category list sorted the way a PivotTable would sort it. Because the results spill and update instantly, every number you later attach to these labels stays in sync with the data.
Now try it in the lab above: build the sorted category list in H2, the distinct count in L2 and the two-level list in J2, then answer the PivotTable question in L4. It takes about fifteen minutes, and it is the foundation for every report in the rest of the course.
Frequently asked questions
How do I get a list of unique values in Excel without a PivotTable?
Use =UNIQUE(range), for example =UNIQUE(C2:C21). In Microsoft 365 and Excel 2021 or later the distinct values spill into the cells below automatically.
How do I sort a unique list alphabetically in Excel?
Wrap UNIQUE in SORT: =SORT(UNIQUE(C2:C21)). Add -1 as the third argument, =SORT(UNIQUE(C2:C21),,-1), for Z to A.
How do I count distinct values in Excel?
Count the rows of the unique list: =ROWS(UNIQUE(C2:C21)) or =COUNTA(UNIQUE(C2:C21)). If the list already spills from H2, =ROWS(H2#) gives the same result.
What does the # after a cell reference mean in Excel?
H2# is the spill range operator. It refers to the entire dynamic array that spills from H2, so formulas that use it grow and shrink with the list.
Why does my UNIQUE formula show #SPILL!?
One or more cells in the area where the results should spill are not empty. Select the error, choose Select Obstructing Cells from the warning menu and clear those cells.
Can formulas replace a PivotTable in Excel?
Yes. Row labels come from SORT(UNIQUE()), values from SUMIFS or COUNTIFS, column headers from TRANSPOSE(UNIQUE()) and filters from criteria cells. The formula report updates instantly and can be laid out freely.
Keep going: Pivot-Style Summary Reports with Formulas: UNIQUE, SUMIFS, Cross-Tabs & Subtotals
This free lab is lesson 1 of 20. Unlock the other 19 hands-on labs, the final exam and your certificate for a one-time $9.90.
- Values: SUMIFS over the Spilled Labels (H2#)
- Cross-Tabs: Rows × Columns with UNIQUE, TRANSPOSE and One SUMIFS Grid
- Show Values As: % of Grand Total, % of Row and % of Column
- Count, Average, Max and Distinct Count: COUNTIFS, AVERAGEIFS, MAXIFS
- Report Filters: Criteria Cells, (All) and a Drill-Down List
- Grouping Dates by Month and Quarter: EOMONTH and Text Keys
- Mid-course project: A Subtotal Report, a Summary that Ignores It, and a Chart
- Show Values As Difference From: Month-on-Month Change and a Base Region
- Running Total In and % Running Total: Cumulative Months by Category
- % of Parent Row Total: Shares Inside a Two-Level Region / Category Report
- Show Values As Index: Which Region Over- or Under-Sells a Category?
- Calculated Fields Done Right: Margin % as a Ratio of Sums, Not an Average of Ratios
- Empty Items, (blank) Labels and Zeros: A Report That Shows Every Row
- Custom Groups with a Mapping Table: Products into Departments and the Unmapped Check
- Grouping Numbers: Order-Size Bands Like "Starting at 0, By 500"
- Grouping by Week and by Weekday: Monday Week Keys and a Weekday Profile
- GROUPBY and PIVOTBY: The Whole Report in One Formula, Checked Against SUMIFS
- Working from a Pasted PivotTable: Fill Down Row Labels and Unpivot a Cross-Tab
- Final Project: A Filtered H1 Summary Dashboard with KPIs, a Category Report and a Trend Chart