Transforming
Tabular Data
Master the essential skills to filter, sort, and transform datasets: the foundation of every data-driven business decision.
What Is Tabular Data?
Tabular data is information organized into rows and columns, much like a spreadsheet. Each row represents a single record (a customer, a transaction, a product), and each column represents an attribute (name, date, price).
Why Transform Data?
Raw data is rarely in the format you need for analysis. Transforming data means reshaping, cleaning, and reorganizing it so you can extract actionable insights quickly and accurately.
Data Transformation in Business
Every business function relies on transformed data. Whether you are in marketing, finance, or operations, the ability to slice, dice, and reshape datasets determines how fast you can move from question to answer.
The Three Core Operations
Filtering: Selecting Rows
A filter applies a Boolean condition to each row. Only rows where the condition evaluates to TRUE are retained. In formal notation:
Sorting: Ordering Rows
Sorting rearranges every row according to the values in one or more columns. The dataset retains all its rows: only the order changes.
Transform: Reshaping Data
Transformations change the structure or values of the table itself. This includes creating new columns, aggregating rows, or reshaping the layout entirely.
Filter vs. Sort vs. Transform
| Filter | Sort | Transform | |
|---|---|---|---|
| Row count changes? | Yes: fewer rows | No: same rows | Maybe: aggregation reduces |
| Column count changes? | No | No | Yes: new or fewer columns |
| Order changes? | No | Yes: reordered | Maybe |
| Values change? | No | No | Yes: computed / aggregated |
Step-by-Step Workflow
Example 1: Filtering a Sales Table
Task: From the sales table below, keep only transactions from the East region with revenue above $10,000.
| ID | Product | Revenue | Region |
|---|---|---|---|
| 001 | Widget A | $12,400 | West |
| 002 | Widget B | $18,200 | East |
| 003 | Widget C | $7,500 | East |
| 004 | Widget D | $21,300 | East |
| 005 | Widget E | $9,800 | North |
Example 2: Sorting by Multiple Keys
Task: Sort the table by Region (ascending), then by Revenue (descending) within each region.
| ID | Product | Revenue | Region |
|---|---|---|---|
| 004 | Widget D | $21,300 | East |
| 002 | Widget B | $18,200 | East |
| 003 | Widget C | $7,500 | East |
| 005 | Widget E | $9,800 | North |
| 001 | Widget A | $12,400 | West |
Example 3: Transforming with Aggregation
Task: Group by Region and compute total revenue and average revenue per region.
Creating Computed Columns
A computed column derives its value from other columns using a formula. The original columns are preserved, and a new column is added.
| Product | Revenue | Cost | Profit (new) |
|---|---|---|---|
| Widget A | $12,400 | $8,200 | $4,200 |
| Widget B | $18,200 | $11,000 | $7,200 |
| Widget C | $7,500 | $6,100 | $1,400 |
Common Mistakes
Operations Summary
| Property | Filter | Sort | Transform |
|---|---|---|---|
| Purpose | Subset rows | Reorder rows | Reshape / compute |
| Input | Boolean predicate | Column + direction | Formula or function |
| Output rows | \( \leq n \) | \( = n \) | Varies |
| Output columns | Same | Same | May add or reduce |
| Typical order | 1st | 3rd (last) | 2nd |
| Example tool | WHERE clause | ORDER BY clause | SELECT computed |
Question 1 of 5
A dataset has 1,000 rows. You apply a filter that keeps rows where \( \text{Revenue} > \$50,000 \). Which statement is always true about the result?
Question 2 of 5
You sort a sales table by Date (ascending), then by Revenue (descending). Two transactions occurred on the same date. Which appears first?
Question 3 of 5
A table has columns: Product, Revenue, Cost. You create a new column \( \text{Margin} = \frac{\text{Revenue} - \text{Cost}}{\text{Revenue}} \). This operation is best described as:
Question 4 of 5
You have 10,000 rows of order data. You need the top 20 orders by revenue in the West region. What is the most efficient order of operations?
Question 5 of 5
After grouping 500 sales records by Region (4 unique regions) and computing \( \text{SUM}(\text{Revenue}) \), how many rows does the result contain?