01 / 21

Transforming
Tabular Data

Master the essential skills to filter, sort, and transform datasets: the foundation of every data-driven business decision.

Business Analytics

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).

ID Product Revenue Region 001 Widget A $12,400 West 002 Widget B $18,200 East 003 Widget C $7,500 East Rows Columns

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.

Filter
Keep only the rows that meet specific criteria, removing noise from your analysis.
Sort
Arrange rows in a meaningful order: ascending, descending, or by custom priority.
Transform
Create new columns, aggregate values, or reshape the table for a different view.

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.

1
Marketing: Filter customers by purchase history to target campaigns.
2
Finance: Sort transactions by date to reconcile accounts.
3
Operations: Transform shipment data to calculate average delivery times.
4
HR: Filter and aggregate employee data for headcount reporting.

The Three Core Operations

Raw Dataset FILTER Select rows SORT Reorder rows TRANSFORM Reshape / compute Analysis- Ready Data

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:

Equality
\( \text{Region} = \text{"East"} \)
Comparison
\( \text{Revenue} > \$10,000 \)
Compound
\( \text{Region} = \text{"East"} \) AND \( \text{Revenue} > \$10,000 \)

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.

Ascending
Smallest to largest: \( 1, 2, 3 \dots \) or A, B, C.
Descending
Largest to smallest: \( 100, 50, 10 \dots \) or Z, Y, X.

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.

1
Computed columns: Derive new values, e.g., \( \text{Profit} = \text{Revenue} - \text{Cost} \).
2
Aggregation: Collapse rows with functions like \( \text{SUM} \), \( \text{AVG} \), \( \text{COUNT} \), \( \text{MAX} \).
3
Pivot / Unpivot: Rotate rows into columns (or vice versa) for cross-tabulation.
4
Data type conversion: Change text to numbers, dates to quarters, etc.

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

1
Understand the question: What business question are you trying to answer?
2
Inspect the raw data: Identify columns, data types, and row count. Note any missing values.
3
Filter first: Remove irrelevant rows to reduce the dataset before further processing.
4
Transform next: Create computed columns or aggregate as needed.
5
Sort last: Arrange the final result for readability or ranking.
6
Validate: Spot-check results against known values or expected totals.

Example 1: Filtering a Sales Table

Task: From the sales table below, keep only transactions from the East region with revenue above $10,000.

IDProductRevenueRegion
001Widget A$12,400West
002Widget B$18,200East
003Widget C$7,500East
004Widget D$21,300East
005Widget E$9,800North

Example 2: Sorting by Multiple Keys

Task: Sort the table by Region (ascending), then by Revenue (descending) within each region.

IDProductRevenueRegion
004Widget D$21,300East
002Widget B$18,200East
003Widget C$7,500East
005Widget E$9,800North
001Widget A$12,400West

Example 3: Transforming with Aggregation

Task: Group by Region and compute total revenue and average revenue per region.

Source (5 rows) East $21,300 East $18,200 East $7,500 North $9,800 West $12,400 GROUP Result (3 rows) Region SUM AVG East $47,000 $15,667 North $9,800 $9,800 West $12,400 $12,400 East AVG:
\( \frac{21,300 + 18,200 + 7,500}{3} = \$15,667 \)

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.

ProductRevenueCostProfit (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

Sorting Before Filtering
Sorting all 100,000 rows first, then filtering to 500 wastes time. Filter first to work with less data.
Confusing Filter with Delete
Filtering hides rows temporarily. Deleting removes them permanently. Always filter: never delete raw data.
Wrong Sort Order
Sorting text as numbers (or vice versa) produces wrong results. "$9,800" sorts alphabetically after "$12,400" if treated as text.

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?