A repeatable process for turning any messy export into an analysis-ready table. Run it
top to bottom every time and you'll never again wonder "did I forget something?" The steps
map directly onto the tabs in this workbook; worked numbers match the sample data.
Golden rule: never clean in place. Keep the raw export on its own tab (`01-Dirty
Data`) and build everything else from it. If a step goes wrong, you can always start over
from the original.
Spend two minutes seeing what you're dealing with before changing anything.
=ROWS(A:A) and eyeball the headers.=UNIQUE(E2:E23) shows every spelling ofCountry at once — the fastest way to spot USA / U.S.A. / Unites States.
=COUNTBLANK(C2:C23).This tells you which of the steps below you actually need.
Leading, trailing, and double spaces are the most common (and most invisible) defect. TRIM
fixes all three.
=TRIM(B2)
" john SMITH " → john SMITH; "Aisha Khan" → Aisha Khan. Test it with
=EXACT(B2, TRIM(B2)) — any FALSE had hidden spaces.
Pick one convention per column. Names → PROPER; emails and codes → LOWER; country/state
abbreviations → UPPER.
=PROPER(TRIM(B2)) =LOWER(TRIM(C2)) =UPPER(TRIM(StateCode))
Watch the PROPER edge cases (McDonald, iPhone, O'Connor is fine) and fix the few
exceptions by hand.
Make every value in a column look identical:
(555) 207-3322.=TEXT(DATEVALUE(F2), "yyyy-mm-dd") collapses four input formats into one.=VALUE(SUBSTITUTE(SUBSTITUTE(G2,"$",""),",","")) turns "$3,450.50" intoa real number 3450.5.
A column you can't SUM or SORT correctly isn't clean yet.
Map every variant to one canonical value using the Normalization Map and XLOOKUP. After
this step, COUNTIF(Country, "United States") returns the true count instead of being split
across eight spellings.
One value per cell. Split Full_Name into first/last with SPLIT/TEXTSPLIT if you need to
sort by surname; combine City + State only for display, never for storage.
Decide per column — don't leave it to chance:
"Unknown" / "N/A" so blanks don'tmasquerade as zero. =IF(TRIM(H2)="", "Unknown", H2).
AVERAGE), *not* 0.Numbers stored as text are the classic silent bug (they left-align and break SUM). Force
the type: =VALUE(text) for numbers, =DATEVALUE(text) for dates. Confirm with =ISNUMBER.
Apply the checks from 04-Validation Rules as columns. A master flag —
=IF(COUNTIF(RuleCols, FALSE)=0, "OK", "Needs review") — turns the sheet into a self-audit.
Fix or quarantine every Needs review row before moving on.
Only now, with formats normalized, is your match key reliable. Build it, flag duplicates with
the running COUNTIF, and filter to Keep. In the sample this drops records 19–22 and
leaves 18 unique customers.
Order matters: clean before you dedup.
"John.Smith@EXAMPLE.com "and
"john.smith@example.com"only collapse into one once Steps 1–2 have run.
Run the descriptive statistics. An IQR fence test (Q1 − 1.5·IQR, Q3 + 1.5·IQR) flags
values that deserve a second look. In the sample it catches ORD-1031 at $20,000. An outlier
isn't automatically wrong — it might be a real whale of a deal — but every one earns a
"is this right?" check before you report an average.
Reconcile. Does the cleaned row count make sense (22 raw − 4 dupes = 18)? Does the pivot
grand total equal the sum of the source rows ($87,449.00 both ways)? Does spend per
customer look plausible? A number that doesn't tie out is a bug, not a feature.
README cell or tab — future-you willthank you.
fast.
| # | Step | Tool |
|---|---|---|
| 1 | Trim whitespace | TRIM |
| 2 | Fix case | PROPER / LOWER / UPPER |
| 3 | Standardize formats | phone/date/currency formulas |
| 4 | Normalize categories | XLOOKUP + map |
| 5 | Split / combine fields | SPLIT / & |
| 6 | Handle blanks | IF(...="", ...) |
| 7 | Fix data types | VALUE / DATEVALUE |
| 8 | Validate | rule columns + master flag |
| 9 | Deduplicate | match key + COUNTIF / UNIQUE |
| 10 | Find outliers | QUARTILE + IQR fences |
| 11 | Reconcile totals | SUM cross-checks |
| 12 | Document & freeze | Paste Special → Values |
Pin this list next to your monitor. Cleaning data well is not about cleverness — it's about
running the same boring checklist every single time.
Questions about applying this to your data? Email support@datanest.dev.
Five copy-paste recipes for summarizing the transactions in 06-Pivot Source, each shown
two ways: as a pivot table (fast) and as a formula (so you can see exactly how the
number is built). Every figure below matches the sample data, which totals $87,449.00
across 31 orders.
Source columns: `A Order_ID · B Order_Date · C Region · D Category · E Segment · F Quantity
· G Unit_Price_USD · H Revenue_USD`.
1. Click any cell inside the data, or select A1:H32.
2. Google Sheets: Insert → Pivot table → *New sheet*. Excel: Insert → PivotTable → OK.
3. The editor shows four drop zones: Rows, Columns, Values, Filters.
4. Drag fields into the zones as each recipe describes. Money fields go to Values, set to
SUM (Sheets) / Sum of (Excel).
That's the whole skill. The recipes below are just different combinations of those drop
zones.
The classic two-dimensional summary.
Pivot table: Region → Rows, Category → Columns, Revenue_USD → Values (Sum).
Formula version (this is what 07-Pivot Summary does):
=SUMIFS('06-Pivot Source'!$H:$H,
'06-Pivot Source'!$C:$C, $A2,
'06-Pivot Source'!$D:$D, B$1)
with regions in A2:A5 and category headers in B1:D1. Drag across and down.
Result:
| Region | Hardware | Software | Services | Total |
|---|---|---|---|---|
| North | 7,695 | 10,875 | 7,950 | 26,520 |
| South | 1,450 | 1,691 | 3,180 | 6,321 |
| East | 7,980 | 7,875 | 31,100 | 46,955 |
| West | 3,500 | 1,513 | 2,640 | 7,653 |
| Total | 20,625 | 21,954 | 44,870 | 87,449 |
The story: East dominates (54% of revenue) and Services is the biggest category —
but East's Services number ($31,100) is inflated by one giant order (see Recipe 5 and the
outlier note in the statistics tab).
To group by month you need a month key, because the dates are daily.
Add a helper column on the source (say column I): =TEXT(B2, "yyyy-mm") → 2024-01.
Pivot table: Month helper → Rows, Revenue_USD → Values (Sum). (In Excel you can instead
drag the real Order_Date to Rows and right-click → Group → Months.)
Formula version:
=SUMIFS('06-Pivot Source'!$H:$H, '06-Pivot Source'!$I:$I, "2024-01")
Result:
| Month | Revenue | Orders |
|---|---|---|
| 2024-01 | 9,092 | 6 |
| 2024-02 | 13,924 | 6 |
| 2024-03 | 14,678 | 6 |
| 2024-04 | 15,484 | 6 |
| 2024-05 | 34,271 | 7 |
Revenue climbs steadily, then May spikes — partly real growth, partly the $20,000 outlier
order. Always reconcile a suspicious jump against the order detail before celebrating.
Pivots happily show more than one measure at once.
Pivot table: Segment → Rows; drag Revenue_USD to Values twice — set the first to
SUM and the second to COUNT (Sheets: summarize by COUNTA; Excel: Count).
Formula version:
Revenue: =SUMIF('06-Pivot Source'!$E:$E, $A2, '06-Pivot Source'!$H:$H)
Orders: =COUNTIF('06-Pivot Source'!$E:$E, $A2)
Result:
| Segment | Revenue | Orders | Avg order |
|---|---|---|---|
| Enterprise | 73,475 | 16 | 4,592.19 |
| SMB | 13,974 | 15 | 931.60 |
Enterprise is 84% of revenue from 52% of the orders — each enterprise deal is worth
roughly 5× an SMB one. That single comparison often reshapes where a team spends its time.
AVERAGEIFS)Sums can hide a lot; averages reveal deal size.
Pivot table: Region → Rows, Revenue_USD → Values, then set *Summarize by* → Average.
Formula version:
=AVERAGEIFS('06-Pivot Source'!$H:$H, '06-Pivot Source'!$C:$C, $A2)
Result: East 5,869, North 3,315, West 1,093, South 790. East's high
average is again the outlier's fingerprint — compare it with East's *median* (Recipe 5's
caution) before reading too much into it.
Pivot table: Region → Rows, Revenue_USD → Values, then *Show values as* → **% of grand
total** (Excel) / *Show as → % of grand total* (Sheets).
Formula version:
=SUMIF('06-Pivot Source'!$C:$C, $A2, '06-Pivot Source'!$H:$H) / SUM('06-Pivot Source'!$H:$H)
Format as percent.
Result: East 53.7%, North 30.3%, West 8.8%, South 7.2%. Two regions make
up 84% of revenue — a textbook concentration that's worth knowing before you plan headcount
or inventory.
Caution on averages and outliers. Recipes 4 and 5 are both skewed by
ORD-1031($20,000, East/Services). When one order can move a regional average by thousands, report
the median alongside the mean, or exclude flagged outliers and note that you did. The
statistics tab gives you the fences to defend that decision.
Once you have monthly revenue in B2:B6, a cumulative column is one anchored SUM:
=SUM($B$2:B2)
Drag down: 9,092 → 23,016 → 37,694 → 53,178 → 87,449. The final running total must equal the
grand total — a built-in reconciliation check.
QUERY (Google Sheets)When you want a quick cut without building a pivot table, QUERY does grouping, sorting, and
labeling in a single cell:
=QUERY('06-Pivot Source'!A1:H32,
"select C, sum(H), count(A), avg(H)
group by C
order by sum(H) desc
label sum(H) 'Revenue', count(A) 'Orders', avg(H) 'Avg'", 1)
For a full cross-tab in one cell, add a pivot clause:
=QUERY('06-Pivot Source'!A1:H32, "select C, sum(H) group by C pivot D", 1)
Excel users get the same flexibility from a real PivotTable or from SUMIFS/AVERAGEIFS
grids as shown above.
| Symptom | Cause | Fix |
|---|---|---|
| Numbers won't SUM (counts instead) | Revenue imported as text | Re-import as number, or =VALUE() the column |
| A category is split in two | Trailing space / casing (Services vs Services) | Clean the source first (Steps 1–2 of the checklist) |
| Can't group by month | Dates are text, not real dates | =DATEVALUE() the column, then group |
| Totals look too high | Blank rows merged into the range | Select an exact range; remove blank rows |
| Pivot won't refresh new rows | Range was fixed (A1:H32) | Use a Table (Excel) or whole-column range, then Refresh |
Questions about a cut that isn't here? Email support@datanest.dev.