๐ 8 Essential Data Transformation Techniques
๐ Data Transformation
If raw data is a pile of random ingredients from different farms, Transformation is the kitchen. It washes the dirt off the vegetables (cleaning), cuts them to the same size (standardization), mixes them together (aggregation), and adds spices (enrichment) so they are ready to be served as a meal.
Transformation is the "T" in ETL/ELT. It is the heavy lifting of the data pipeline where raw data is converted into a format that is useful for business analysis.
Without transformation, raw data is messy, inconsistent, and untrustworthy.
๐ ๏ธ Core Transformation Techniques
Here are the 8 most common transformations applied to data before it hits the warehouse.
1๏ธโฃ Cleaning (Cleansing)
Removing or fixing corrupt, incomplete, or inaccurate data.
- Null handling: Replace missing salaries with
0or missing names with"Unknown". - Deduplication: Remove duplicate rows if a customer accidentally clicked "Submit" twice.
- Trimming: Remove accidental spaces (e.g.,
" Raj "becomes"Raj").
2๏ธโฃ Standardization
Ensuring all data follows a single consistent format, regardless of the source.
| Source | Raw Data | Standardized |
|---|---|---|
| CRM | gender = M | gender = Male |
| ERP | date = 21/06/2024 | date = 2024-06-21 |
| Web | city = BLR | city = Bangalore |
3๏ธโฃ Mapping
Translating values from the source system into the target system's vocabulary.
- Source System uses:
Status: 1, 2, 3 - Data Warehouse requires:
Status: Pending, Shipped, Delivered - Mapping translates
1 โ Pending,2 โ Shipped, etc.
4๏ธโฃ Aggregation
Summarizing detailed data into a higher-level view. This reduces data volume and speeds up reporting.
- Raw: Every single item scanned at a supermarket checkout.
- Aggregated: Total sales amount per store, per day.
-- Example Aggregation
SELECT store_id, SUM(amount) AS daily_sales
FROM raw_orders
GROUP BY store_id;
5๏ธโฃ Enrichment
Adding new information to the data by joining it with other datasets.
- Raw: A web log has an IP address (
192.168.1.1). - Enriched: Join it with a GeoIP database to add
City: Mumbai, Country: India.
6๏ธโฃ Filtering
Removing rows that the business doesn't need for analysis.
- Drop all records where
test_user = TRUE. - Drop all transactions from the year 2010 (if the business only analyzes the last 5 years).
7๏ธโฃ Validation (Business Rules)
Checking if the data makes logical business sense. If it fails, the row is rejected or flagged.
Order Datecannot be in the future.Customer Agecannot be-5or150.Transaction Amountcannot be negative (unless it's a refund).
8๏ธโฃ Encoding & Formatting
Changing data types or masking sensitive data for security.
- Type casting: Convert a string
"100"to an integer100. - Data Masking (PII): Change a credit card number
1234-5678-9012-3456toXXXX-XXXX-XXXX-3456.
๐๏ธ Where Does Transformation Happen?
Depending on whether you use ETL or ELT, the location changes:
- ETL: Happens in a middle-tier transformation server (like Informatica or Talend) before it hits the Data Warehouse.
- ELT: Happens directly inside the Data Warehouse or Data Lake (using SQL, dbt, or Spark) after the raw data is loaded.
In modern stacks, SQL is the primary language of transformation. Tools like dbt (data build tool) allow engineers to write standard SELECT statements to clean and transform data inside platforms like Snowflake or BigQuery.
๐งช Practice Drill
// Try answering these:
// Q1. A source system sends customer names as `" amit "`. The transformation layer changes it to `"Amit"`. What specific technique is this?
// Q2. An analyst wants to see total monthly revenue, but the source data contains every individual transaction. Which transformation technique is needed?
// Q3. The source system sends `CountryCode = IN`. The data warehouse needs `CountryName = India`. What is this process called?
// Q4. Why is Data Masking an important part of the transformation process?
// Q5. Match the raw data scenario to the correct transformation technique:
// | Raw Data Scenario | Transformation Technique |
// | ------------------------------------------------- | ------------------------ |
// | Converting string "2024" to an integer. | ? |
// | Rejecting an employee record because `Age = 12`. | ? |
// | Replacing `gender = Null` with `"Not Specified"`. | ? |
// | Taking an IP address and adding the user's City. | ? |
๐ก Click for Solutions
A1. Cleaning (Specifically, Trimming and Capitalization).
A2. Aggregation. You need to group by month and sum the transaction amounts.
A3. Mapping (or Standardization).
A4. To protect PII (Personally Identifiable Information) like credit cards, passwords, or social security numbers before the data is exposed to business analysts in the warehouse.
A5.
| Raw Data Scenario | Transformation Technique |
|---|---|
| Converting string "2024" to an integer. | Encoding / Type Casting |
Rejecting an employee record because Age = 12. | Validation (Business Rules) |
Replacing gender = Null with "Not Specified". | Cleaning (Null Handling) |
| Taking an IP address and adding the user's City. | Enrichment |
โ Previous Topic | Next Topic โ Next Topic