Lesson 2.4: Rapid Data Transformation: Flash Fill, Text to Columns & Deduplication
Rapidly clean, restructure, and deconstruct messy columns using Flash Fill, delimited Text to Columns, and the Remove Duplicates utility.
π₯ Video Chapter: Chapter 2 β Data Management (16:05)
Why This Matters
Data analysts frequently receive exports where multiple attributes are crammed into a single cell or transaction tables containing repeated dimensional entities. Excel's built-in transformation tools allow instant parsing and restructuring without complex formulas or external ETL code.
Core Concepts
- Flash Fill (
Ctrl + E): Machine-learning driven pattern detection that parses, merges, or restructures text based on sample manual entries. - Text to Columns (
Alt + A + E): Converts delimited text strings (commas, tabs, hyphens, pipes, spaces) into distinct adjacent columns. - Remove Duplicates (
Alt + A + M): Scans specified columns for duplicate key combinations and purges redundant rows.
1. Text to Columns: Parsing Superstore Product IDs
The Sample Superstore dataset (<a href="/COURSE-EXCEL-ZERO-TO-HERO/reference/sample-superstore-dataset-documentation/" class="internal-link">Sample Superstore Dataset Documentation</a>) encodes 3 hierarchical attributes into the Product ID column (e.g., FUR-BO-10001798):
- Department Code:
FUR(Furniture),OFF(Office Supplies),TEC(Technology) - Sub-Category Code:
BO(Bookcases),CH(Chairs),PH(Phones),LA(Labels) - Item Serial Number:
10001798(unique 8-digit item identifier)
Step-by-Step Delimited Extraction
- Select the
Product IDcolumn range (L2:L9995). - Press
Alt + A + E(or Data > Text to Columns). - Step 1 of 3: Select Delimited β Click Next.
- Step 2 of 3:
- Uncheck Tab.
- Check Other and type hyphen
-in the delimiter box. - Preview window shows 3 distinct columns.
- Step 3 of 3:
- Set Destination cell to empty adjacent columns (e.g.,
T2) to preserve the rawProduct ID. - Select Column 3 (
10001798) and explicitly choose Text format to avoid stripping leading zeros if serials contain them.
- Set Destination cell to empty adjacent columns (e.g.,
- Click Finish.
Raw Product ID: FUR-BO-10001798
β
[Text to Columns: '-']
β
ββββββββββββββββββββββΌβββββββββββββββββββββ
βΌ βΌ βΌ
[Col 1: Dept] [Col 2: Sub-Cat] [Col 3: Serial]
"FUR" "BO" "10001798"
2. Flash Fill (Ctrl + E): Order ID Decomposition
In <a href="/COURSE-EXCEL-ZERO-TO-HERO/reference/sample-superstore-dataset-documentation/" class="internal-link">Sample Superstore Dataset Documentation</a>, Order ID combines country, order year, and order sequence:
CA-2016-152156 or US-2015-108966.
Flash Fill detects patterns instantaneously without touching formulas:
| Row | Raw Order ID (Col B) |
Extracted Year (Col U) | Action / Shortcut |
|---|---|---|---|
| Row 2 | CA-2016-152156 |
2016 |
Type 2016 manually in U2 and press Enter |
| Row 3 | CA-2016-152156 |
2016 |
Press Ctrl + E (Excel auto-fills all 9,994 rows) |
| Row 4 | US-2015-108966 |
2015 |
Auto-populated |
| Row 22 | CA-2014-115812 |
2014 |
Auto-populated |
Flash Fill produces static values. If your underlying data updates frequently, prefer dynamic formula extractions like =TEXTBEFORE(TEXTAFTER(B2, "-"), "-") or Power Query. For one-off ad-hoc cleaning across 10,000 rows, Flash Fill takes 2 seconds.
3. Deduplication: Transactional vs Dimensional Granularity
In retail datasets like Superstore, orders frequently contain multiple items:
- Total Rows:
9,994transaction line-items - Unique Orders:
5,009orders - Unique Customers:
793customers
If an analyst clicks Remove Duplicates on Order ID, Excel will permanently delete 4,985 line items, destroying multi-product baskets and understating total revenue by over $1,100,000!
Correct Deduplication Workflow (Building a Customer Dimension Table)
- Copy the
Customer ID,Customer Name, andSegmentcolumns to a new sheet. - Select the copied columns (
A1:C9995). - Press
Alt + A + M(or Data > Remove Duplicates). - Ensure My data has headers is checked.
- Select Customer ID as the sole primary key check.
- Excel reports:
"9201 duplicate values found and removed; 793 unique values remain."
- You now have a verified Customer Dimension Table with zero data corruption to the underlying sales ledger.
Practical Lab Exercise & Demo Workbook
- Demo Workbook:
11_Demos_and_Workbooks/02_Data_Management/Superstore_Dataset_Demo.xlsxOrder Year: Extracted using=YEAR([@[Order Date]])and formatted as integer0.Gross Revenue: Calculated catalog price before discount:=[@Sales] / (1 - [@Discount]).Net Revenue: Realized revenue after discount:=[@Sales] * (1 - [@Discount]).Dept,Sub-Cat,Serial: Decomposed fromProduct IDvia Delimited Text to Columns or=TEXTSPLIT([@[Product ID]], "-").Dim_CustomersTab: Deduplicated customer dimension table (793 distinct customer entities).
Related Knowledge
- Concepts: Data Cleaning, Power Query, Excel File Formats
- Dataset: Sample Superstore Dataset Documentation
- Formulas: TEXTJOIN, TRIM, TEXTSPLIT
- Student Workbook:
11_Demos_and_Workbooks/02_Data_Management/Superstore_Dataset_Demo.xlsx