Cleaning Data

Learn to turn messy data into data you can trust. Check data integrity and profile a dataset to find its problems, then remove duplicates, handle missing values, clean text, unify date, number and unit formats and convert data types, using spreadsheet functions and SQL queries side by side. Finish by documenting every change and verifying the cleaned data, so others can follow, repeat and trust your work.

BeginnerLesson 4 of 7 in Data Analytics Foundations Course

What you will learn

  1. Explain what makes data trustworthy, recognize the common kinds of dirty data, and inspect a dataset systematically to list its problems before changing anything.
    • Explain data integrity and the kinds of dirty data
      Describe what data integrity means, what can damage it, and the main kinds of dirty data an analyst has to find and fix.
    • Profile a dataset to find its problems
      Inspect a new dataset with sorting, filtering, counts and simple summaries in a spreadsheet and in SQL, and turn what you find into a list of problems to fix.
    • Check entries against validation rules
      Define the rules that valid data must follow, test existing data against them in a spreadsheet and in SQL, and use data validation to stop invalid entries where they are typed.
  2. Find records that appear more than once and decide which to keep, and find, interpret and treat missing values so that totals, counts and averages stay honest.
    • Find and remove duplicate records
      Decide what makes a record unique, find exact and near duplicates with spreadsheet functions, built-in tools and SQL, and remove them without losing real data.
    • Find missing values and see how tools count them
      Recognize the different forms missing data takes, check for them correctly in spreadsheets and SQL, and understand how functions and aggregates treat blanks, zeros and NULL.
    • Decide how to treat missing values
      Choose between recovering, removing, filling, flagging or leaving missing values, apply the choice with spreadsheet formulas and SQL, and judge how it changes the results.
  3. Make values that mean the same thing look the same: clean and restructure text, use one format for dates, numbers and units, and convert values to the data type the analysis needs.
    • Clean and standardize text values
      Remove extra spaces and hidden characters, unify letter case, replace and map spelling variants to one standard value, in spreadsheets and in SQL.
    • Split, combine and extract parts of text
      Give each piece of information its own column by splitting at a separator or extracting characters by position, and build combined values when they are needed.
    • Use consistent formats for dates, numbers and units
      Recognize the date and number conventions in a dataset, tell display format apart from stored value, and convert mixed units so that every value in a column means the same thing.
    • Convert values to the right data type
      Recognize values stored with the wrong data type, convert text to numbers and dates in spreadsheets and with SQL CAST, keep identifiers as text, and catch values that fail to convert.
  4. Combine the cleaning techniques into a safe, repeatable workflow: helper columns and built-in tools in a spreadsheet, and a cleaning query in SQL, using the tool that suits the data.
    • Run a cleaning workflow in a spreadsheet
      Set up a safe working copy, apply cleaning steps in a sensible order with helper columns, lookups and built-in tools, and turn the checked results into a clean table.
    • Write a SQL query that returns clean data
      Build a SELECT query that cleans columns with functions, CASE and COALESCE, filters or flags invalid rows, and save it so the cleaning can be repeated, while knowing when changes to stored data are appropriate.
  5. Record every cleaning step so others can follow and repeat it, then check that the cleaned data is correct and complete and report what changed and what limits remain.
    • Keep a record of every cleaning step
      Write a changelog and comments that record what was changed, why, how and with what effect, so the cleaning can be checked, repeated and explained.
    • Verify the cleaned data and report the results
      Check that the cleaning fixed the problems without creating new ones, reconcile counts and totals with the raw data, and write a short cleaning summary for the people who use the data.

Cleaning Data study guide

5 chapters

1

Judge data integrity and find dirty data

A useful cleaning plan starts with a clear picture of the table and the question it must answer. Inspect how records are organized, find the fields that identify them, and count the problems before changing values. Rules based on field meanings help distinguish a real error from a rare but valid entry. The starting profile will also give you a baseline for checking the result after the fixes are applied.

1.1 Explain data integrity and the kinds of dirty data

An accurate-looking table can still give the wrong answer. Cleaning starts with the meaning of its records: what happened, who or what each row describes, and which fields the analysis needs.

What data integrity means

Data integrity means accuracy, completeness, consistency and trustworthiness throughout the data's life cycle. Values must match the facts they claim to record. Required information must be present, and the same fact must keep the same meaning as it moves between systems.

Integrity can break during entry, storage, transfer or analysis. Someone may mistype a quantity. Copies in two systems can drift apart, a problem called replication. An interrupted transfer can load half a file. Sorting one column alone can attach each amount to the wrong order. System failures and unauthorized changes can also damage records.

Recognize the problem before fixing it

Dirty data is incomplete, incorrect, inconsistent or irrelevant to the question. Different problems need different actions.

ProblemWhat you might seeWhat needs checking
Duplicate recordOne order ID appears twiceWhether both rows describe one event
Missing valueAn order has no amountWhether the amount can be recovered
Inconsistent text"Lisbon", "lisbon " and "LISBON"Which values share a meaning
Invalid valueAn age of 230The allowed range and original entry
Outdated valueA customer's previous addressThe relevant date and current source
Wrong typeA quantity stored as textHow the software treats the value

A neat format does not establish accuracy. A delivery date can look like a date but still occur before the order date. A test customer can have a complete record but be irrelevant to actual customer sales.

Follow the effect on an answer

Suppose order 1003, worth 250.00, appears twice in an export. Counting rows adds one extra order, and summing amounts adds 250.00 too much. The formulas can work perfectly while the input gives a false result. Text variants create another problem: a chart can divide Lisbon's sales between separate city labels.

Clean data is fit for the analysis being done. A missing middle name has no effect on sales by region. A missing order amount does affect total sales. Judge completeness against the fields needed for the question, then record gaps that remain.

Protect the starting point

Keep an untouched raw copy before making changes. Use another file, a separate sheet or the original database table, and clean a working copy. A tool such as Remove Duplicates deletes rows from its selected range; the raw copy gives you something to compare with and a way to redo a decision.

Work through five stages: inspect, decide, apply, document and verify. Record a problem before choosing its treatment. Record each treatment when you apply it, then check the result against the raw data. Internal data needs the same inspection as an external file: repeated imports and changed field meanings happen inside organizations too. Tell the data owner about recurring entry or export problems so the next delivery improves.

Key Takeaways

  • Integrity depends on accuracy, completeness and consistency across the data life cycle.
  • Dirty data includes duplicates, gaps, inconsistent values, invalid entries, outdated information and wrong types.
  • Judge whether data is clean against the analysis it must support.
  • Keep raw data untouched, and inspect, decide, apply, document and verify.

1.2 Profile a dataset to find its problems

Data profiling is a systematic inspection of a dataset before changing it. It gives you a baseline and a problem list: the size of the table, the contents of each column, gaps, repeated keys and values that need investigation.

Start with the table's structure

Identify what one row means, such as one order or one customer. Check for one header row and one kind of information per column. Find the key, the column or combination of columns that should identify one record. A repeated order ID needs investigation; repeated city names are expected.

Record the starting row count. Then inspect each column's expected type, required status and allowed values. A data dictionary or the data owner supplies these meanings. The minimum and maximum can reveal a date outside the reporting period or a placeholder such as 999 in an age column.

Inspect a spreadsheet

Sort and filter the table, keeping whole rows together. Sort ascending and descending to find blanks, unexpected text and extreme values. Filter dropdowns reveal category spellings. Excel filters ignore case, so a single displayed category can hide capitalization differences; use EXACT when case itself needs checking. Conditional formatting can highlight repeated keys and values outside a range.

For rows 2 through 501, useful checks include:

  • =COUNTA(B2:B501) counts nonempty cells.
  • =COUNTBLANK(B2:B501) counts blanks, including formulas that return empty text.
  • =COUNT(B2:B501) counts numeric cells.
  • =MIN(B2:B501) and =MAX(B2:B501) show the numeric range.
  • =COUNTIF(C2:C501,"Lisbon") counts matching entries, ignoring case.

If an amount column's numeric count is smaller than its nonempty count, inspect the difference. Some entries may be numeric text; others may be labels such as "N/A". A space-only cell also needs attention even though it looks blank.

Inspect with SQL

These queries read the data without changing it:

SELECT COUNT(*) AS rows_total,
       COUNT(amount) AS amounts_present,
       COUNT(*) - COUNT(amount) AS amounts_missing,
       MIN(order_date) AS first_date,
       MAX(order_date) AS last_date
FROM orders;

COUNT(*) counts rows. COUNT(amount) counts non-NULL amounts. Their difference counts missing amounts represented by NULL, but it does not detect text placeholders.

To inspect category values and their frequency:

SELECT city, COUNT(*) AS n
FROM orders
GROUP BY city
ORDER BY city;

GROUP BY collects equal values; COUNT(*) counts the rows in each group. NULL forms its own group. Text equality follows the database's comparison settings, called collation. PostgreSQL and SQLite ordinarily separate case variants; common MySQL settings combine them.

Turn checks into a problem list

For six amounts 40, NULL, 25, 60, NULL and 35, the row count is 6 and the present count is 4: two amounts need attention. For cities "Lisbon", "lisbon ", "Porto", NULL, "LISBON" and "Porto", exact text comparison finds four non-NULL spellings, although only two cities are represented.

Write down both findings, along with the affected column and count. Inspect frequent values and extremes for hidden placeholders, test records and dates such as "1900-01-01". Profiling the whole table first also reveals dependencies: trimming text can change the duplicate count, so duplicate removal should wait until the comparison fields are standardized.

Key Takeaways

  • Record table structure, row meaning, keys and starting counts before cleaning.
  • Use counts, distinct values, frequencies and ranges to find problems across whole columns.
  • COUNT(*) counts rows; COUNT(column) skips NULL.
  • Blank counts miss placeholders and space-only text.
  • Check text-comparison settings before interpreting category counts.

1.3 Check entries against validation rules

Data validation checks whether entries follow rules for acceptable data. An entry can be present and neatly displayed while breaking a rule. A quantity of -3 is still invalid when order quantities must be positive.

Choose rules from the data's meaning

Read the data dictionary or ask the data owner. A hotel day-use booking may allow zero nights; another booking system may require at least one. Write the actual limit and whether the field is required.

RuleQuestion it answersExample
TypeIs the value the right kind?Quantity is numeric
RangeIs it inside the allowed limits?Percentage is from 0 to 100
FormatDoes it follow the required pattern?Code has three letters and four digits
ListIs it an allowed category?Status is "open", "shipped" or "returned"
PresenceIs a required value supplied?Order ID is not missing
UniquenessDoes a key occur only once?No repeated order ID
ConsistencyDo related fields agree?Delivery date is on or after order date

A format check tests a pattern, not whether the underlying fact is true. A basic email check for one "@" and text on each side cannot confirm that a mailbox exists.

Flag failures in a spreadsheet

Put a test in a helper column and fill it down. For a required numeric percentage in B2, =AND(ISNUMBER(B2),B2>=0,B2<=100) checks both type and range. The type test matters because a blank can behave like zero in a comparison.

With real dates in C and D, =IF(D2<C2,"check","ok") flags a delivery before its order. Check required dates for blanks separately. For IDs in column A, =COUNTIF($A$2:$A$501,A2)>1 flags repeated values. Filter the helper results to see every failure.

List failures with SQL
SELECT * FROM orders
WHERE quantity <= 0 OR quantity IS NULL;

This finds nonpositive and missing quantities. To check statuses:

SELECT * FROM orders
WHERE status NOT IN ('open', 'shipped', 'returned')
   OR status IS NULL;

The explicit NULL check matters. NOT IN alone does not return a row with a NULL status, because its comparison is unknown. A cross-field check such as delivery_date < order_date also needs separate presence checks for required dates.

Prevent new errors and resolve old ones

Excel's Data Validation and Google Sheets' Data validation can provide a dropdown, restrict a number range, or warn about an entry. Database types and constraints such as NOT NULL and UNIQUE enforce related rules. Adding a rule does not repair old records; inspect those separately. Excel's Circle Invalid Data can mark existing failures.

Consider adult survey ages 34, 0, 41, 230 and "forty", with a whole-number range of 18 to 120. "forty" fails the type check; 0 and 230 fail the range check. The word has the clear numeric meaning 40. The intended value of 230 is uncertain, so do not guess between 23 and 30. Recover a reliable value, mark it missing or exclude the record, and log the decision.

An unusual value is different from an invalid value. An order of 500 units may be real. Validate it against the order rules and source record before deciding it is an error.

Key Takeaways

  • Validation rules come from field meanings and the data owner’s requirements.
  • Use type, range, format, list, presence, uniqueness and consistency checks.
  • Check NULL explicitly when a SQL rule must also catch missing values.
  • Entry controls prevent some new errors; existing records still need checks.
  • Correct failures from evidence, mark them missing or exclude them, and log the action.
  • A rare but allowed value is not invalid just because it is large.
2

Remove duplicates and handle missing values

Repeated records and missing values can change counts, totals and averages in different ways. Decide what makes a record unique before deleting copies, and learn how blanks, text placeholders and NULL affect calculations. Missing information may be recovered, kept visible, excluded or estimated. Each choice needs a reason tied to the analysis, along with a record of which rows or values it affects.

2.1 Find and remove duplicate records

Two similar rows are not necessarily one record entered twice. A duplicate describes the same real-world entity or event as another row. Begin by deciding what identifies that entity or event.

Define the key and comparison rules

An order ID can identify an order. A name alone is usually a poor customer key because different people can share it. Even two identical purchases on the same day can be real separate events. Check the row meaning and the data owner's key before deleting look-alike rows.

Exact duplicates match in all columns. Near duplicates refer to the same thing but have small differences, such as an extra space or a changed phone number. Clean the comparison fields before searching. If email is the agreed key, normalize spacing and case in a helper column.

For five emails "ana@example.com", "ben@example.com", "Ana@Example.com ", "chen@example.com" and "ben@example.com", exact raw comparison finds the repeated Ben entry. Trimming and lowercasing also reveals Ana's repeated entry. Three customer keys remain after removing two extra copies.

Flag rows before removing them

For cleaned keys in B2:B501:

  • =COUNTIF($B$2:$B$501,B2)>1 flags every row whose key repeats.
  • =COUNTIF($B$2:B2,B2)>1 flags only the second and later occurrences.

The second range grows as you fill down, so the first occurrence has a count of one. COUNTIF ignores letter case; trim first to handle extra spaces. Inspect flagged groups for conflicting information before applying a keep rule.

Choose what survives

Excel's Remove Duplicates and Google Sheets' Remove duplicates compare the columns you select. Selecting email alone can discard a row with a different phone number. Selecting all columns keeps that conflict because the full rows differ. Both tools use their own matching rules, including case-insensitive comparisons, so they are unsuitable for enforcing character-by-character case distinctions without an additional check.

Excel keeps the first occurrence. If the latest record should survive, sort the complete rows by update date first, with the newest first. Resolve tied or conflicting records explicitly. A documented rule might keep the most recently confirmed record or merge verified fields. Log both the chosen columns and the number removed.

=UNIQUE(A2:C501) returns distinct rows into a new range in current Excel and Google Sheets. It preserves the source and is useful for previewing a result.

Find repeated keys with SQL
SELECT email, COUNT(*) AS n
FROM customers
GROUP BY email
HAVING COUNT(*) > 1;

GROUP BY creates a group for each email; HAVING keeps groups whose count exceeds one. WHERE filters individual rows before grouping. Run the check on standardized keys, either by using a cleaned table or grouping by the cleaning expression.

SELECT DISTINCT email, name FROM customers; returns each email-and-name combination once. It does not guarantee unique emails: two rows with one email and different names both remain. Check the agreed key after deduplication.

Repeated imports and overlapping exports often create duplicates. Record the cause with the data owner so a fix to today's table also improves the next export.

Key Takeaways

  • Define the real record key before deleting repeated-looking rows.
  • Standardize comparison fields so near duplicates can be found.
  • A growing COUNTIF range flags later copies; a fixed range flags every repeated copy.
  • The columns selected in Remove Duplicates determine which differences are ignored.
  • DISTINCT compares selected result rows, not a business key.
  • Resolve conflicting duplicates with a stated keep or merge rule.

2.2 Find missing values and see how tools count them

A gap can be visible as a blank or hidden behind a plausible-looking value. Find out how the source records missing information before counting it. A recorded zero may be real, while "unknown" may be a placeholder.

Distinguish blanks, text and NULL

In a spreadsheet, an empty cell, a cell containing a space, and a formula returning "" can look alike. ISBLANK is true only for a genuinely empty cell. A space is text. COUNTBLANK also counts formulas returning empty text, but it does not count a cell containing a space. For ordinary spaces, =TRIM(B2)="" detects both empty and space-only entries.

Spreadsheet SUM, AVERAGE and COUNT skip empty cells and text in a referenced range. They include numeric zero. For amounts 48, 52, a blank, 45, a blank, 55, 50 and 46, the known amounts sum to 296. AVERAGE divides by six, giving about 49.33. Replacing the blanks with zero changes the denominator to eight and the average to 37.

In SQL, NULL marks an unknown or absent value. Zero is a known number. The empty string '' is text with no characters in PostgreSQL, MySQL, SQL Server and SQLite. Imported blanks may appear in either form, so check the stored representation:

SELECT * FROM orders
WHERE city IS NULL OR TRIM(city) = '';

Use IS NULL and IS NOT NULL. amount = NULL does not find missing amounts: comparison with NULL produces an unknown result, which WHERE does not retain.

Know the denominator

COUNT(*) counts all rows. COUNT(amount), SUM, AVG, MIN and MAX skip NULL amounts. For 40, NULL, 25, 60, NULL and 35, there are six rows but four known amounts. SUM is 160 and AVG is 40 because it divides 160 by four.

These functions cannot identify a numeric placeholder such as -1 or 999. Confirm placeholder meanings with the data owner, then count them separately or normalize them to missing. Inspect the frequencies of unusual codes as well as blank counts.

Look for patterns in the gaps

Count missing entries per column and as a share of rows. Two missing amounts out of eight is 25%. Then inspect whether gaps cluster by store, source or month. A missing field confined to one export source may point to an import problem that can be repaired.

The reason for missingness matters:

  • Missing completely at random: an unrelated event, such as a random save failure, causes the gap.
  • Missing at random: the chance of a gap depends on recorded information, such as older customers skipping an optional online field more often.
  • Missing not at random: the chance depends on the missing value itself, such as very high earners leaving income blank.

In the income case, the average among respondents may be lower than the average for everyone. Filling gaps with one number does not remove that selection problem. Report what is missing and who the remaining values describe before interpreting an average.

Key Takeaways

  • NULL, an empty string, a blank cell and zero represent different states.
  • Use IS NULL in SQL; equality with NULL does not find missing values.
  • COUNT(*) includes every row, while COUNT(column) and common numeric aggregates skip NULL.
  • A numeric zero contributes to a spreadsheet average; an empty cell does not.
  • Count gaps and inspect their pattern before choosing a treatment.

2.3 Decide how to treat missing values

Missing values need a decision tied to the question being answered. A customer without an age can still contribute to total sales. An order without an amount cannot contribute a known value to revenue.

Choose an action
ActionWhen it helpsWhat to record
RecoverA reliable source supplies the true valueSource and correction
Leave missingThe gap can remain visibleMissing count and effect on the analysis
ExcludeRequired data is unavailableRows excluded and why
FillA justified replacement is usefulReplacement rule and affected values
FlagReaders need to distinguish missing or filled entriesMeaning of the flag

Try recovery first. Check an invoice, original form or system of record. A line total derived from verified quantity and unit price is recovered information. A value estimated from other customers is an estimate, called imputation.

Preserve what a number means

Filling a category with "Unknown" keeps the row in counts while exposing the gap. Filling a numeric field with zero is justified only when missing actually means zero. A missing return count can mean zero if the source process confirms that convention; an unknown sale amount has no such meaning.

For known amounts 48, 52, 45, 55, 50 and 46, the sum is 296 and the mean is about 49.33. With two blanks changed to zero, the sum remains 296 but the average falls to 37. The extra rows now count as observations of zero.

Mean or median filling also changes the data. The median of the six known amounts is 49. Filling both gaps with 49 adds 98, making the mean of the eight entries 49.25. Those two added values were not observed. Repeated central values make the data look less spread out, so keep a flag identifying them. For strongly skewed values such as incomes, the median often describes a typical value better than the mean.

Apply the rule visibly

In SQL, COALESCE(city, 'Unknown') returns the first non-NULL argument. It fills NULL cities but leaves an empty string unchanged. NULLIF(city, 'N/A') turns exactly that placeholder into NULL. Combining normalization and filling makes the treatment explicit:

COALESCE(NULLIF(TRIM(city), ''), 'Unknown') AS city

A spreadsheet category helper can use =IF(TRIM(B2)="","Unknown",B2). A separate flag can use =TRIM(B2)="" so the original missing status remains visible after filling.

Match exclusions to the analysis

For total revenue from 1,000 orders with three missing amounts, seek the invoices first. If recovery fails, report that the total excludes 3 of 1,000 orders, or 0.3%. Do not discard a row because an unused field is blank.

If 400 of 1,000 customer ages are missing, filling with the mean would turn 40% of the column into estimates. An analysis of the 600 known ages needs a clear statement about its coverage. Check why those ages are absent: deleting rows can also distort results when those customers differ from the rest. Keep the treatment consistent and document any later change to it.

Key Takeaways

  • Recover true values before considering estimates.
  • Choose treatment according to missingness, field meaning and the analysis.
  • Zero filling changes counts and averages even when the sum stays the same.
  • Mean and median fills are estimates and need flags.
  • Keep and report rows that are complete for the actual question.
3

Standardize text, formats and data types

Spaces, letter case, combined fields and mixed formats can stop software from recognizing equal values. Work from the meaning and source convention of each column, then choose a consistent form. Text functions prepare labels for comparison; parsing converts values into usable types; unit conversion gives quantities a shared scale. Check the stored result as well as its display, especially for dates and digit-based identifiers.

3.1 Clean and standardize text values

Text cleaning makes values with the same meaning comparable. Start by listing the distinct values and their counts. That reveals whether a column needs spacing changes, consistent case or a mapping from several spellings to one label.

Remove spaces and hidden characters

In Excel and Google Sheets, =TRIM(A2) removes spaces at both ends and reduces repeated internal spaces to one. It turns " Ana Silva " into "Ana Silva". =CLEAN(A2) removes nonprinting characters such as line breaks.

A nonbreaking space copied from a web page can survive TRIM. Replace character 160 with an ordinary space first:

=TRIM(SUBSTITUTE(A2,CHAR(160)," "))

Read nested functions from the inside out: SUBSTITUTE runs first, then TRIM acts on its result. Inspect cleaned examples because removing a line break can join words that should stay separate.

SQL TRIM(city) removes spaces at the ends but leaves repeated internal spaces. TRIM(' Ana Silva ') therefore retains three spaces between the names. LTRIM changes the left end and RTRIM the right. Choose a cleaning expression that matches the characters you found.

Standardize case deliberately

UPPER and LOWER work in both tools. Lowercase can be a useful email convention; uppercase can suit country codes. A spreadsheet's PROPER capitalizes words, but it cannot establish the correct spelling of a name: "mcdonald" becomes "Mcdonald" and "PT123" becomes "Pt123". Review names and keep codes in their intended case.

Text comparisons follow tool settings. Excel's COUNTIF, VLOOKUP and filters ignore case. PostgreSQL ordinarily treats "Lisbon" and "LISBON" as different text values. Spreadsheet =EXACT(A2,B2) checks identical text including case. Standardize explicitly when the same category must work consistently across tools, while preserving meaningful case distinctions in case-sensitive identifiers.

Map whole values to one category

Trimming and case changes do not fix different spellings. A mapping table can pair each variant with a standard label. Look up the complete cleaned value with exact match, and inspect values that have no match.

In SQL, CASE can express the same mapping:

CASE
  WHEN UPPER(TRIM(country)) IN
       ('NL', 'NETHERLANDS', 'THE NETHERLANDS', 'HOLLAND')
    THEN 'Netherlands'
  ELSE TRIM(country)
END AS country

The ELSE preserves unmapped values for review. Count the remaining categories after mapping; do not assume the first few rows represent all spellings.

Avoid replacement damage

SUBSTITUTE, Find and Replace, and SQL REPLACE can replace text inside a longer value. Replacing "NY" everywhere changes "Store NYC, NY" to "Store New YorkC, New York". For category labels, match the entire cell or use a mapping table. For addresses and names, inspect the intended scope of each replacement.

For cities "Lisbon", "lisbon ", "Porto", a missing value, "LISBON" and "Porto", UPPER(TRIM(city)) produces LISBON three times and PORTO twice, with one gap. Analyze the cleaned column, then use it for matching and duplicate checks. Keeping the helper while grouping the raw city would preserve the original problem.

Key Takeaways

  • Spreadsheet TRIM also reduces internal spaces; SQL TRIM normally trims only the ends.
  • Replace nonbreaking spaces before trimming when they occur in imported text.
  • Choose case conventions by field and inspect names changed with PROPER.
  • Map spelling variants as whole values and review unmatched entries.
  • Use cleaned fields for later comparisons and analysis.

3.2 Split, combine and extract parts of text

A combined text value can hide information needed for sorting or matching. Put each required piece in its own column, while preserving the original until the split is checked.

Split at a reliable separator

A delimiter marks the boundary between parts. A comma in "Silva, Ana" separates the last name from the first name. Excel's Text to Columns and Google Sheets' Split text to columns let you choose that separator. Insert empty columns to the right before splitting so the output does not overwrite other fields.

Google Sheets can use =SPLIT(A2,","); current Excel can use =TEXTSPLIT(A2,","). Trim the returned pieces if a space follows the comma. Check rows with a missing delimiter or more than one delimiter before applying one rule to the entire column.

Do not split every name at a space. "Ana Maria Silva" has more parts than a two-word name, and a space alone does not establish which words belong to a first or last name. Use a defined source layout or keep a full-name field when the structure is uncertain.

Extract by position when the layout is fixed

For product code "PT-LIS-0042", the country occupies positions 1–2, the location positions 4–6, and the final code positions 8–11.

FormulaResultReason
=LEFT(A2,2)"PT"First two characters
=MID(A2,4,3)"LIS"Three characters starting at position 4
=RIGHT(A2,4)"0042"Last four characters
=LEN(A2)11Total characters, including dashes

Position counting starts at one. Preserve the extracted code as text so its leading zeros survive. Fixed positions work only when the field layout is consistent.

For variable-length text, locate the delimiter. In "Silva, Ana", FIND(",",A2) returns 6. =LEFT(A2,FIND(",",A2)-1) takes the five characters before the comma. The subtraction excludes the comma itself. FIND is case-sensitive; SEARCH ignores case when searching letters.

Use the equivalent SQL function

SUBSTRING(code, 4, 3) extracts the middle location code in PostgreSQL; some databases use SUBSTR. Character-length functions also vary: PostgreSQL and SQLite use LENGTH, MySQL uses CHAR_LENGTH, and SQL Server uses LEN, which ignores trailing spaces. MySQL LENGTH counts bytes, so it can differ from the character count for text such as "é".

A PostgreSQL check WHERE LENGTH(code) <> 11 finds wrong-length codes. A length check alone does not establish that the letters, digits and dashes are in the correct places.

Combine parts with a clear separator

=A2&" "&B2 or =CONCATENATE(A2," ",B2) joins two spreadsheet fields with a space. =TEXTJOIN(" ",TRUE,A2:C2) joins a range while skipping empty cells. Excel CONCAT accepts multiple arguments; Google Sheets CONCAT takes exactly two.

In PostgreSQL, first_name || ' ' || last_name concatenates text. With this operator, a NULL part makes the result NULL. CONCAT handles NULL differently across dialects: MySQL propagates it, while PostgreSQL and SQL Server skip it. Treat optional parts deliberately with COALESCE and check the resulting separators.

Key Takeaways

  • Split at a delimiter only when it represents the intended boundary.
  • Use LEFT, MID and RIGHT for fixed layouts, and FIND for variable-length parts.
  • Insert space for split output and keep identifier pieces as text.
  • Character-length functions differ by SQL dialect.
  • Concatenation needs deliberate separators and missing-value handling.

3.3 Use consistent formats for dates, numbers and units

A consistent display is useful only when the values mean the same thing. Dates need a known order, numbers need known separators, and measurements need one unit before calculations begin.

Establish the source convention

The text "03/04/2025" can mean March 4 or April 3. A date such as "25/03/2025" establishes day-first order for that entry, but a combined file can contain several formats. Confirm the convention with the data owner or export settings and check for mixed sources before converting ambiguous entries.

Use ISO 8601 date order, YYYY-MM-DD, for clear exchange: "2025-03-04" names March 4. Uniform ISO date text also sorts chronologically. Use the 24-hour clock for times, such as "14:30", and record a time zone when events span zones.

Separate stored values from display

Spreadsheets store real dates as serial numbers. In Excel's default date system and Google Sheets, January 1, 2025 is 45658 and March 4, 2025 is 45720. Formatting that numeric date as YYYY-MM-DD changes how it appears; it does not change the day recorded.

Text that looks like a date is different. Applying a date format to text does not create a real date value. Check the type and convert the text using the confirmed source layout before formatting it. Alignment can be a clue, but type checks and calculation behavior give stronger evidence because alignment can be changed manually.

Number formatting works the same way. A stored value of 0.125 can display as 0.13 with two decimal places while calculations still use 0.125. =ROUND(A2,2) changes the numeric result to two decimal places. Keep full precision through cleaning unless the field definition requires a rounded value: three thirds rounded separately to 0.33 sum to 0.99.

Read number separators correctly

"1,234.5" and "1.234,5" express the same number under different conventions. Importing with the wrong locale can change the magnitude or leave a value as text. Compare several imported values with their source, including values with decimal and grouping separators.

In Excel, =NUMBERVALUE("1.234,5",",",".") explicitly names the decimal comma and grouping point and returns 1234.5. Set the import locale correctly in other tools. Do not delete every comma without checking its role: it may separate thousands or mark the decimal part.

Convert units before combining values

A weight column containing "2.5 kg", "750 g" and "1.2 kg" mixes labels and units. Extract the number and unit, convert grams to kilograms, and store 2.5, 0.75 and 1.2 in a numeric weight_kg column.

2.5+0.75+1.2=4.45 kg

Adding the raw numeric pieces gives 753.7, which has no consistent unit. Keep one unit in the column header and numbers in the cells. A monetary column likewise needs one currency before totals or averages have a shared meaning; record any conversion rule used.

After conversion, inspect minimum and maximum dates and measurements. Check individual ambiguous dates against the source even when they fall within the allowed period: swapping month and day can produce a valid but incorrect date.

Key Takeaways

  • Confirm date order and number separators before parsing text.
  • Display formats change appearance; type conversion and rounding change values.
  • Use YYYY-MM-DD for clear dates and record time zones where needed.
  • Convert measurements to one unit before summing or averaging them.

3.4 Convert values to the right data type

A data type tells software how to treat a value. Numeric quantities support arithmetic, dates support date sorting and differences, text holds labels and identifiers, and Boolean fields hold TRUE or FALSE. Imports often turn intended numbers or dates into text.

Diagnose the type before changing it

Numeric text may align left by default, show an Excel warning or sort "10" before "9". Check the whole column with COUNT and COUNTA. In a referenced range containing numeric 120, text "80" and numeric 45, SUM gives 165 and COUNT gives 2. The intended total is 245, so the type error is affecting the calculation.

Changing the display format to Number does not convert existing text. Make a helper column, convert there, and compare the result with the raw entry.

Convert spreadsheet text

=VALUE(A2) parses numeric text using the spreadsheet locale. =DATEVALUE(A2) parses date text using its recognized date conventions. Confirm separators and date order first.

For a known day-first value "04.03.2025", construct a date from its parts. Explicit VALUE calls make the inputs numeric in both Excel and Google Sheets:

=DATE(VALUE(RIGHT(A2,4)),VALUE(MID(A2,4,2)),VALUE(LEFT(A2,2)))

RIGHT returns the year text "2025", MID returns month text "03", and LEFT returns day text "04". VALUE converts each part; DATE builds March 4, 2025. Validate the parts first: DATE can roll an impossible day or month into a later date instead of reporting an error.

For a value such as " 1250 kg", remove the known unit label and spaces before conversion: =VALUE(TRIM(SUBSTITUTE(A2,"kg",""))). Do not strip arbitrary letters from every field, because letters may be meaningful or may indicate an invalid entry. =IFERROR(VALUE(A2),"check") keeps failed conversions visible for review.

Keep identifiers as text

The code "00427" identifies something; it is not a quantity to add. Conversion to a number gives 427 and loses the leading zeros. Phone numbers, many postal codes and account identifiers also belong in text columns. Set the type before importing. Excel preserves only 15 significant digits in numeric storage, so a 16-digit identifier can lose information before you notice it. Formatting it as text afterwards cannot recover the lost digits.

Convert with SQL and inspect failures

In databases such as PostgreSQL, CAST(amount_text AS DECIMAL(10,2)) parses numeric text and returns a decimal with two places. CAST(quantity_text AS INTEGER) requests a whole number. ISO text can be cast to DATE in many dialects; other date layouts need a matching parser such as PostgreSQL TO_DATE, MySQL STR_TO_DATE or BigQuery PARSE_DATE.

Invalid text often stops a CAST query. SQL Server TRY_CAST and BigQuery SAFE_CAST instead return NULL for failed ordinary conversions. Count these failures separately from values already missing. For example, in SQL Server:

SELECT amount_text FROM sales
WHERE TRY_CAST(amount_text AS DECIMAL(10,2)) IS NULL
  AND amount_text IS NOT NULL;

SQLite can quietly cast "12abc" to 12 and "abc" to 0. A successful query is therefore insufficient evidence of a correct conversion. Check the original strings, converted values, counts and ranges before accepting the clean column.

Key Takeaways

  • Diagnose wrong types using counts and calculation behavior, not appearance alone.
  • Convert text explicitly and inspect failed conversions.
  • Build known-layout dates from numeric parts and validate the parts first.
  • Preserve digit-based identifiers as text before import.
  • Check your SQL dialect: invalid casts may error, return NULL or silently coerce text.
  • Formatting a corrupted identifier cannot restore lost digits.
4

Clean data step by step in a spreadsheet and in SQL

Individual cleaning functions become more useful when they form an ordered process. In a spreadsheet, helper columns let you compare inputs and outputs before creating a fixed clean table. In SQL, expressions and filters can return clean data while preserving the raw source. In both tools, check the effect of each step and save the rules so the same work can be repeated when the next export arrives.

4.1 Run a cleaning workflow in a spreadsheet

A spreadsheet workflow makes each change visible and keeps enough evidence to repeat it. Use a raw sheet, a working sheet with helpers, and a checked clean table.

Set up and order the work

Keep raw data untouched. Freeze the header row and use a table or filters to select the complete data range. When sorting, move whole rows together so names, IDs and amounts remain linked.

A practical sequence is:

  1. Profile the table and write a problem list.
  2. Fix headers and split fields that contain several required pieces.
  3. Trim text, standardize case and map category variants.
  4. Convert types and unify date, number and unit formats.
  5. Treat missing values, preserving flags when needed.
  6. Remove duplicates using the agreed key and keep rule.
  7. Validate, reconcile and spot-check the result.

This order handles dependencies. A duplicate check on raw keys can miss extra spaces. A range test on numeric text may not test the intended values. Record the effect after each step so a later mismatch can be traced to its cause.

Build and inspect helper columns

If B2 contains " ana SILVA", =PROPER(TRIM(B2)) returns "Ana Silva". Fill the formula through the full table and compare raw and cleaned names. Review spellings that PROPER cannot infer correctly.

A helper such as =UPPER(TRIM(SUBSTITUTE(B2,CHAR(160)," "))) works inside out: replace nonbreaking spaces, trim ordinary spaces, then change case. Use descriptive helper headers such as city_clean so later formulas point to the intended column.

Filter results and check values at the beginning, middle and end of the range. A formula copied through only part of the table leaves a mixed column. Look for errors as well as blanks.

Map categories with exact lookup

Keep a two-column mapping table of variant and standard label. With a prepared variant in B2, =VLOOKUP(B2,Map!$A$2:$B$50,2,FALSE) finds the matching label. The absolute references keep the mapping range fixed when filled down. FALSE requests exact match; approximate matching can return a plausible but incorrect category for an unlisted value.

XLOOKUP can use separate lookup and result ranges. Its default is exact match. An unmatched variant should stay visible as an error for review. Add or correct its mapping instead of converting every lookup failure into a familiar category.

Finalize and document

After checking helpers, copy their results and use Paste Special > Values in Excel or Paste special > Values only in Google Sheets to create the clean table. Test that it is independent before deleting source columns: formulas that still refer to deleted cells can return #REF!.

Built-in tools such as Remove Duplicates, Find and Replace and Text to Columns can change many cells at once. Log their options, selected range and affected count while the information is visible. Formula helpers show their logic directly; retain that working sheet with the log.

English formulas here use commas. Spreadsheet language and locale can change function names and separators; for example Dutch Excel uses SPATIES.WISSEN for TRIM, and decimal-comma locales often use semicolons between arguments.

Excel permits 1,048,576 rows and 16,384 columns per worksheet; Google Sheets limits cells per file. Performance can become a problem well before a hard limit. Frequently refreshed data or data already in a database often fits a saved SQL workflow better than repeated manual spreadsheet edits.

Key Takeaways

  • Keep raw, working and checked clean data distinct.
  • Clean structure, text and types before duplicate checks and final validation.
  • Use helper columns and exact-match mappings, then review errors.
  • Paste checked results as values before removing their formula inputs.
  • Log built-in tool options and affected counts as you work.

4.2 Write a SQL query that returns clean data

A SQL cleaning query can return usable data without changing the raw table. Each expression makes a rule explicit, and an alias names the cleaned output.

Build the result a column at a time

The following query is suitable for PostgreSQL when amount and date text have already passed conversion checks and quantity is numeric:

SELECT DISTINCT
  order_id,
  LOWER(TRIM(email)) AS email,
  COALESCE(NULLIF(UPPER(TRIM(city)), ''), 'UNKNOWN') AS city,
  CAST(amount AS DECIMAL(10,2)) AS amount,
  CAST(order_date AS DATE) AS order_date
FROM raw_orders
WHERE order_id IS NOT NULL
  AND quantity > 0;

Email is trimmed and lowercased. For city, TRIM removes end spaces, UPPER standardizes case, NULLIF turns empty text into NULL, and COALESCE supplies "UNKNOWN". The casts return numeric amounts and dates. WHERE excludes missing IDs and nonpositive or NULL quantities. DISTINCT removes repeated selected result rows.

Profile the output after each added expression. A complicated query can run successfully while a mapping or conversion is wrong.

Understand filtering order

The useful logical order is FROM, WHERE, SELECT, DISTINCT, ORDER BY. WHERE sees source columns before the SELECT expressions produce their aliases. An alias does not make a raw column clean inside the same query's WHERE clause.

To filter a raw city consistently, use WHERE UPPER(TRIM(city)) = 'LISBON', or save the cleaned result and filter that result in a later query. Filtering raw city with city = 'LISBON' can miss variants even when SELECT cleans the city it displays.

CASE checks conditions in order and returns the first matching result:

CASE
  WHEN LOWER(TRIM(status)) IN ('shipped', 'sent') THEN 'shipped'
  WHEN status IS NULL THEN 'unknown'
  ELSE LOWER(TRIM(status))
END AS status

Without ELSE, an unmatched value becomes NULL. Keep unmapped statuses visible until their meaning is resolved.

Choose between filtering and flagging

WHERE removes a row from the result. A flag keeps the row and marks an issue, for example CASE WHEN delivery_date < order_date THEN 1 ELSE 0 END AS date_issue. Check required dates separately for NULL.

Count excluded rows explicitly:

SELECT COUNT(*) FROM raw_orders
WHERE order_id IS NULL
   OR quantity <= 0
   OR quantity IS NULL;

This accounts for every reason the earlier filter rejects a row, including missing quantities. After DISTINCT, check the business key with GROUP BY and HAVING. Rows sharing an ID but holding different amounts survive DISTINCT and still need resolution.

Save the method and choose the right dialect

CREATE VIEW clean_orders AS SELECT ... saves a query that reads current source data each time the view is used. CREATE TABLE clean_orders AS SELECT ... creates a stored result in many dialects; SQL Server commonly uses SELECT INTO. Keep the query and comments so you can rebuild that result when inputs change.

Function names and behavior vary across SQL systems. Check the dialect for date parsing, character length and safe conversion. UPDATE and DELETE alter stored records: preview the same WHERE condition with SELECT and have a backup before applying either. Without WHERE, they affect every row. Cleaning through SELECT is a useful default for analysts with read-only access.

Key Takeaways

  • SELECT expressions clean output while leaving raw records unchanged.
  • WHERE reads raw fields before SELECT aliases are produced.
  • CASE chooses the first true condition; ELSE handles unmatched values.
  • Count filtered rows, and check business-key uniqueness after DISTINCT.
  • Save a view or query for repeatable cleaning, and check dialect-specific behavior.
  • Preview and back up before an UPDATE or DELETE changes stored data.
5

Document and verify the cleaning

A finished cleaning job needs evidence that another person can inspect. Record changes and reasons as you work, then compare the clean output with the raw input using counts, totals and validation rules. These checks can reveal accidental losses or transformations that looked harmless. A short report connects the technical work to the coverage and limits of the analysis the clean data will support.

5.1 Keep a record of every cleaning step

A clean table needs an explanation of how it was made. Documentation lets another person trace a reported value, judge a decision and rerun the work on the next delivery.

Write a useful changelog entry

A changelog is a dated record of changes. Each entry should identify:

  • The date and author.
  • The dataset and affected column or range.
  • The problem and its original scale.
  • The action, including formula, query or tool options.
  • The number of rows or values affected.
  • The reason and any source used to confirm a correction.

For example: "2025-03-10, A. Silva, orders.city: 412 values trimmed and set to uppercase with UPPER(TRIM(city)); 9 spellings reduced to 4 cities; needed for sales by city."

That entry explains both the method and its purpose. "Cleaned cities" does not identify the comparison rule, scope or count. Record entries while working so the tool's affected-row message and the reason for a decision are still available.

Record decisions as well as operations

A formula does not explain why it was appropriate. For duplicates, name the key columns and which record survived. For missing amounts, say whether they were recovered, excluded, filled or left missing. If you filled values, record the estimate rule and flag column. For a correction, identify the invoice or source record that supplied the true value.

Log flagged-but-retained rows too. A reviewer needs to distinguish a known issue you kept visible from an issue the cleaning missed. If a treatment changes later, add a dated entry explaining the new decision.

Keep the method and its history

Spreadsheet cell notes can explain one correction, while a Changelog sheet holds the complete sequence. Google Sheets version history can restore earlier file states. Excel Version History is available for files stored in OneDrive or SharePoint. History helps recover a file, but a separate log explains the intent of the changes.

SQL comments can explain a rule next to its expression. Use -- for one line or /* ... */ for a longer comment. Keep query versions in version control or storage with version history. A plain shared folder makes the current query accessible but does not establish earlier versions.

Make rerunning possible

A process is reproducible when the same raw input and rules produce the same clean output. Saved queries and retained helper formulas expose their rules. A manual cell edit needs the record ID, old value, new value and reason if someone is to repeat it accurately.

Keep the raw copy, transformation steps, mapping tables and log together. If a rule depends on a keep order, such as retaining the latest customer record, save the sort or selection rule too. Reproducing a result requires the decisions as well as the software expressions.

Share the log and a short cleaning summary with the people who use the data. Someone interpreting results needs to know that test orders were removed or that ages are missing for part of the customer base. Send recurring source errors to the data owner so they can fix the form, import or export that creates them.

Key Takeaways

  • Record who changed what, when, why, how and how many values were affected.
  • Document key choices, missing-value treatments and sources for corrections.
  • Retain formulas, queries, mappings and version history alongside the raw input.
  • A reproducible process gives the same clean result from the same raw data.

5.2 Verify the cleaned data and report the results

Verification asks whether the cleaning fixed the problems without creating new ones. It also checks that the remaining data still answers the original question. Use whole-column tests and comparisons, then inspect individual records.

Reconcile row counts step by step

Start with the raw row count. Subtract rows removed at each stage, counting each removal once. For 1,250 raw rows, 37 duplicate copies removed and 12 later invalid rows excluded:

1250−37−12=1201

The expected clean count is 1,201. A different count needs an explanation before release. Check the step where the count first diverged. A filter may have hidden rows from a spreadsheet operation, or a selected range may have omitted part of the table.

If one row has several problems, do not subtract it several times. Use the actual row count before and after each operation. Keep distinct counts for rows removed and cells corrected: changing ten city cells does not remove ten rows.

Repeat the profile and rules

Run the original checks on the clean output. Compare each result with the decision recorded in the log:

  • Missing counts match the values left missing, recovered or filled.
  • Category lists have the intended standard spellings.
  • Numeric and date minimums and maximums are valid.
  • The key has no unresolved duplicates.
  • Type, presence, range and consistency checks have no unexplained failures.

A zero blank count after filling does not mean no values were missing. Check the flags too. A repeated business key can remain after DISTINCT when one selected field differs, so test that key directly.

Reconcile amounts and inspect records

When no values were corrected or filled, the clean total should equal the raw total minus the amounts in removed rows. A raw total of 152,400 less 3,100 in removed duplicate orders should leave 149,300. If values were corrected or filled, include those changes separately in the reconciliation.

Compare records from several parts of the table with the raw data and, where possible, the original source. Target the rows affected by risky steps: replacements, splitting, parsing and type conversion. Inspect names for overbroad replacement, columns for shifted split output, identifiers for lost zeros, and dates for swapped day and month. A plausible date can still be the wrong date.

Check the question's coverage

Make sure the clean data still covers the required period, regions, stores, products and fields. Dropping all orders from a store because its dates use another layout changes the population being analyzed. Fix the parsing rule when possible, and report any coverage that remains missing.

Write a short report naming the source and period, problems and counts, actions taken, exclusions or fills, verification results and remaining limits. For example: "Age is missing for 12% of customers; results by age describe the other 88%." A result should be interpreted using that coverage.

Rerun both cleaning and verification when new raw data arrives. Saved rules make the process repeatable, but new categories, changed formats and new missing-value patterns still need review.

Key Takeaways

  • Reconcile actual row removals in sequence without double-counting rows.
  • Rerun profiling and validation on the full clean output.
  • Explain total changes through removals, corrections and fills.
  • Spot-check transformations that can damage identifiers, dates or text.
  • Confirm the clean data still covers the business question.
  • Report unresolved gaps and repeat checks on each new delivery.

Cleaning Data examples

5 Walkthroughs

1

Inspect an order export before changing it

12 steps
Build a baseline, identify problems and turn business meanings into checks.
  1. 1
    IntroductionStart with a question

    You need total order value by city for a reporting period. Before fixing the export, identify which fields support that question: an order ID, date, city and amount. A neat table can still contain repeated orders, gaps or text numbers, which threaten data integrity.

    Keep the export untouched and inspect a working copy, writing a profile of its counts and types as a baseline. The aim is to understand the problems before choosing their treatment, so the fixes preserve the records and fields the analysis needs.

  2. 2
    ExplanationTrace what can go wrong

    Data integrity means accurate, complete, consistent and trustworthy records throughout their life cycle. A mistyped amount damages accuracy; an interrupted import damages completeness; city variants damage consistency.

    The problem may also be introduced during analysis. Sorting amounts alone separates them from their orders. Move whole rows together, and retain the raw copy as evidence of the starting state.

  3. 3
    ExampleFollow one duplicate into a total

    Order 1003 is worth 250.00 and appears twice. A row count treats the copies as two orders. A sum includes both amounts, overstating total sales by 250.00.

    The arithmetic can be correct while the business answer is wrong. Check what the row represents and which key identifies it before deciding whether to keep or remove a repeated-looking entry.

  4. 4
    ChallengeDoes this gap affect the question?

    The city and amount fields are complete for a set of orders, but several customer middle names are missing. Must those orders be removed to total sales by city?

    ---reveal---

    No. Their required city and amount values are available. A missing middle name does not prevent this analysis. Keep the usable orders and note the unused name gaps; deleting them would remove known sales.

  5. 5
    ExplanationWrite the starting profile

    Record the row count, column names and the meaning of one row. Identify the order key and inspect each field’s expected type. Then count missing values, list categories and check numeric and date ranges.

    Keep this profile with the problem list. It supplies a baseline for later checks and reveals dependencies: trimming keys may expose duplicates that a raw comparison misses.

  6. 6
    ExampleCount known and missing amounts

    The amounts are 40, NULL, 25, 60, NULL and 35. SQL COUNT(*) gives 6 because it counts every row. COUNT(amount) gives 4 because it skips NULL.

    Subtract the present count from the row count: two amounts are missing. This check finds SQL NULLs; it does not detect a placeholder such as -1. Inspect frequent values and ranges as well as missing counts.

  7. 7
    ExampleInspect the category list

    The city values are "Lisbon", "lisbon ", "Porto", NULL, "LISBON" and "Porto". Under exact text comparison, there are four distinct non-NULL strings but only two intended cities.

    A GROUP BY query lists category values with their counts, including a NULL group. Check the database’s comparison settings: case variants may combine. In Excel, filter lists ignore case, so they do not reveal every capitalization difference.

  8. 8
    ChallengeInterpret a count mismatch

    An amount column has 160 nonempty spreadsheet cells, but COUNT returns 153. What should you investigate?

    ---reveal---

    Seven nonempty cells are not numeric. Inspect them for numeric text, placeholders or other text before converting or filling anything. The difference identifies records to inspect; it does not establish that all seven are missing amounts.

  9. 9
    ExplanationTurn meanings into rules

    Rules define acceptable values. Check type, range, pattern, allowed categories, required presence, key uniqueness and relationships between fields.

    For an order, a positive quantity rule and a delivery-on-or-after-order rule test different things. Confirm both with the data owner. A rare quantity can still be valid, so do not confuse an unusual observation with an impossible one.

  10. 10
    ExampleCatch invalid and absent statuses

    Allowed statuses are "open", "shipped" and "returned". In SQL, find failures with:

    WHERE status NOT IN ('open', 'shipped', 'returned')
       OR status IS NULL
    

    The list test catches unrecognized non-NULL codes. The separate NULL test catches absence. Without it, a required missing status would escape this failure list because its comparison is unknown.

  11. 11
    ChallengeChoose the next action

    A profile finds quantity -4 and quantity 400. Order quantities must be positive whole numbers, and no maximum is specified. How should the two entries be treated?

    ---reveal---

    -4 breaks the rule and needs recovery, a missing marker or exclusion with a logged reason. The value 400 passes the stated rule; investigate it if needed, but do not change it merely for being rare. Preserve the baseline so later checks can trace any correction.

  12. 12
    RecapCarry a problem list into cleaning

    Your inspection should now leave a usable record of the table’s structure, key, starting counts and problems. The rules say which values are unacceptable; the profile says where and how often the problems occur.

    Choose treatments from that evidence. Keep row relationships intact, preserve the raw input, and retain the baseline for verifying the completed cleaning.

2

Resolve repeated orders and missing amounts

14 steps
Work from record keys and missing-value behavior to defensible treatments.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionSeparate two different problems
  2. 2
    ExplanationAgree on the key
  3. 3
    ExampleNormalize customer emails
  4. 4
    ExampleChoose the flag you need
  5. 5
    ChallengeWill DISTINCT solve this conflict?
  6. 6
    ExplanationIdentify how gaps are stored
  7. 7
    ExampleCompute the observed average
  8. 8
    ChallengeCompare two apparently blank cells
  9. 9
    ExplanationSeek the true value first
  10. 10
    ExampleSee the effect of zero filling
  11. 11
    ExampleKeep estimates visible
  12. 12
    Key InsightA gap pattern can change the interpretation
  13. 13
    ChallengeChoose fields for exclusion
  14. 14
    RecapLeave a defensible result
3

Turn mixed text into usable fields

17 steps
Clean labels, separate fields and convert dates, measurements and types without losing meaning.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionChange the representation carefully
  2. 2
    ExplanationRemove accidental spacing
  3. 3
    ExampleMap variants to a standard label
  4. 4
    ChallengeCheck what PROPER can know
  5. 5
    ExampleLocate fixed parts of a code
  6. 6
    ExplanationFind a changing boundary
  7. 7
    ChallengeHandle optional text parts
  8. 8
    ExplanationEstablish the date before formatting it
  9. 9
    ExampleConvert a mixed-unit measurement
  10. 10
    ChallengeDisplay or stored result?
  11. 11
    ExplanationDiagnose numeric text
  12. 12
    ExampleBuild a known-layout date
  13. 13
    ExampleKeep failures separate from gaps
  14. 14
    ChallengePreserve a numeric-looking identifier
  15. 15
    TipPoint later work at the cleaned fields
  16. 16
    ChallengeAudit an import across fields
  17. 17
    RecapCheck meaning as well as form
4

Build a repeatable cleaning workflow

13 steps
Assemble checked spreadsheet helpers and a SQL cleaning query, then preserve the method.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionSave the work as a process
  2. 2
    ExplanationSet the order of spreadsheet steps
  3. 3
    ExampleBuild the helper from the inside out
  4. 4
    ExampleReview a category mapping
  5. 5
    ChallengeFinish a checked clean column
  6. 6
    ExplanationReturn a cleaned SQL column
  7. 7
    ExampleNormalize and fill a city
  8. 8
    ExampleAdd a deliberate filter
  9. 9
    ChallengeChoose a filter or a flag
  10. 10
    Key InsightAn alias cannot repair an earlier filter
  11. 11
    TipSave the query with the right persistence
  12. 12
    ChallengeCheck a complete method
  13. 13
    RecapRetain outputs and rules
5

Verify and explain the finished data

10 steps
Build a useful log, reconcile the output and describe its remaining limits.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionMake the result reviewable
  2. 2
    ExplanationWrite the entry while working
  3. 3
    ExampleTurn a vague log into evidence
  4. 4
    ChallengeCan this manual correction be repeated?
  5. 5
    ExampleReconcile the row count
  6. 6
    ExampleReconcile the amount total
  7. 7
    ExplanationRepeat the rules and inspect risky changes
  8. 8
    ChallengeDoes the table still answer the question?
  9. 9
    ChallengeConnect the log to the final report
  10. 10
    RecapDeliver a result with its evidence

Cleaning Data practice questions

50 Practice Questions in 5 sets

Set 1: Apply cleaning functions and interpret results10 Practice Questions

Question 1 of 10

A PostgreSQL text column uses exact comparison. It contains "Lima", "LIMA", "Lima ", NULL and "Cusco". What does COUNT(DISTINCT city) return?
  1. 2
  2. 3
  3. 4
  4. 5
Show answerHide answer
Answer: C
The three Lima spellings are distinct under the stated comparison, and Cusco adds a fourth non-NULL value. COUNT(DISTINCT city) skips NULL, so the answer is four. Counting two confuses the intended city meanings with the distinct stored strings.

Question 2 of 10

A required numeric percentage must be between 0 and 100. A blank cell passes the helper =AND(B2>=0,B2<=100). How should the helper be improved?
  1. Add ISNUMBER(B2) to the AND test.
  2. Change the lower limit from 0 to 1.
  3. Use OR between the existing comparisons.
  4. Format B2 with a percent symbol only.
Show answerHide answer
Answer: A
The numeric type check rejects a blank while preserving the valid endpoints 0 and 100. Comparisons alone can treat a blank like zero, letting a missing required value pass. Raising the lower limit would also reject a genuine zero, which the rule permits.

Question 3 of 10

A customer table is used to total purchase_amount by region. Many rows have blank favorite_color, but complete amounts and regions. What deletion rule fits this analysis?
  1. Delete every row with any blank field.
  2. Delete rows whose favorite_color is absent.
  3. Fill favorite_color before retaining any rows.
  4. Check completeness in amount and region.
Show answerHide answer
Answer: D
The analysis requires purchase amounts and regions, so assess gaps in those fields. Blank favorite colors do not make those records unusable for the stated total. Deleting every incomplete row would unnecessarily remove known sales and could change the regional comparison.

Question 4 of 10

A warehouse records an empty damage count when a completed inspection finds no damage. The owner confirms that convention. How can the empty counts be standardized for this field?
  1. Fill them with the mean of positive counts.
  2. Fill them with zero and record the convention.
  3. Exclude them as inspections with unknown results.
  4. Fill them with the most common positive damage count.
Show answerHide answer
Answer: B
Here the confirmed field convention gives the blank a known meaning: zero damage found. Zero filling records that meaning and should be documented. Excluding those inspections as unknown would discard observed no-damage cases and make the retained inspections look more damaged.

Question 5 of 10

A2 holds "CA-TOR-0086", a fixed-format code. What formula extracts "TOR"?
  1. =MID(A2,3,3)
  2. =MID(A2,4,4)
  3. =RIGHT(A2,3)
  4. =MID(A2,4,3)
Show answerHide answer
Answer: D
The location starts at character 4 and occupies three characters, so MID needs a start of 4 and a length of 3. Starting at character 3 includes the preceding dash and misses the final letter. RIGHT with three characters takes the end of the numeric code instead.

Question 6 of 10

A spreadsheet range contains numeric 18, text "24", numeric 30 and a genuinely empty cell. What do COUNT and SUM return for that range?
  1. COUNT 3; SUM 72
  2. COUNT 4; SUM 72
  3. COUNT 2; SUM 48
  4. COUNT 3; SUM 48
Show answerHide answer
Answer: C
COUNT includes the two numeric cells, and SUM adds 18 and 30 to give 48. The referenced text "24" and the empty cell are skipped. A total of 72 assumes the text entry was converted, but no conversion has taken place.

Question 7 of 10

A2 contains a last name followed by a comma and first name. Last names have different lengths. What formula returns the last name without the comma?
  1. =LEFT(A2,FIND(",",A2)-1)
  2. =LEFT(A2,FIND(",",A2))
  3. =RIGHT(A2,FIND(",",A2)-1)
  4. =MID(A2,FIND(",",A2),1)
Show answerHide answer
Answer: A
FIND locates the comma, and subtracting one gives the number of characters before it. LEFT returns that portion regardless of the last name’s length. Omitting the subtraction includes the comma, so the extracted name would still carry its delimiter.

Question 8 of 10

A PostgreSQL raw table has numeric quantity and validated numeric amount text. Rows are (id 41, city " Bern ", amount "9", quantity 1), (41, "BERN", "9", 1), (41, "Bern", "12", 1), and (42, "Bern", "7", NULL). A query selects DISTINCT id, UPPER(TRIM(city)), and CAST(amount AS DECIMAL(10,2)), with WHERE quantity > 0. How many result rows remain, and is id unique?
  1. 2 rows; id is repeated.
  2. 1 row; id is unique.
  3. 3 rows; id is repeated.
  4. 2 rows; id is unique.
Show answerHide answer
Answer: A
The NULL-quantity row is filtered out. The first two remaining rows become identical, but the amount 12 keeps the third distinct from amount 9, leaving two rows with id 41. DISTINCT therefore removes one repeated result row without establishing unique IDs.

Question 9 of 10

A regional comparison starts with 120 rows. Eight extra duplicate copies and 11 invalid-date rows are identified; three invalid rows are also those extra copies. All six rows for one region are among the invalid-date rows. Cleaning removes every identified row. What clean count and coverage assessment should the review report?
  1. 101 rows; one required region is absent.
  2. 104 rows; one required region is absent.
  3. 107 rows; all required regions remain.
  4. 104 rows; all required regions remain.
Show answerHide answer
Answer: B
After the eight duplicate removals, eight invalid rows remain because three were already removed. The clean count is therefore 104, and removing every invalid-date row also removes the six rows for one required region. Reconciliation must avoid double-counting the overlap and still report the lost regional coverage.

Question 10 of 10

A SQL amount column contains 10, NULL, 20 and 0. What does AVG(amount) return?
  1. 7.5
  2. 15
  3. 10
  4. 30
Show answerHide answer
Answer: C
AVG skips the NULL but includes the recorded zero, so it divides a sum of 30 by three known values to return 10. Dividing by all four rows gives 7.5 and treats the missing amount as zero. Excluding the real zero instead would give 15.
Set 2: Recognize problems and choose first checks10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A repair log has service dates and costs, but some technician middle names are blank. The analysis needs monthly repair cost. How should those blanks be treated?
  1. Exclude every repair with a missing middle name.
  2. Keep the repairs and leave those names missing.
  3. Fill the names from the most common technician.
  4. Fill blank names from the latest repair record.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A table has 240 rows, and SQL COUNT(weight_kg) returns 226. How many rows have a NULL weight?
  1. 226 rows
  2. 240 rows
  3. 466 rows
  4. 14 rows
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A form accepts only the statuses "new", "active" and "closed". What kind of validation rule does this define?
  1. An allowed-list check
  2. A uniqueness check
  3. A numeric-range check
  4. A cross-field check
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A booking table contains two rows with booking_id 812, but different phone numbers. The data owner confirms one booking per ID. What should happen before either row is removed?
  1. Keep the row with the alphabetically first phone number.
  2. Keep both because unequal rows cannot be duplicates.
  3. Resolve the conflict using a supported keep or merge rule.
  4. Remove both because their shared key makes each invalid.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A spreadsheet cell A2 contains one ordinary space. What do ISBLANK(A2) and TRIM(A2) return?
  1. ISBLANK TRUE; trimmed text empty.
  2. ISBLANK FALSE; trimmed text empty.
  3. ISBLANK FALSE; trimmed text nonempty.
  4. ISBLANK TRUE; trimmed text nonempty.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

The text " Mina Cho " is in A2. What does spreadsheet TRIM(A2) return?
  1. "Mina Cho" with one internal space
  2. "Mina Cho" with three internal spaces
  3. "MinaCho" with no internal space
  4. "mina cho" with lowercase letters
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A city helper contains =UPPER(TRIM(A2)). What is the order of its operations?
  1. Uppercase the text, then replace every space.
  2. Replace hidden characters, then lowercase the text.
  3. Uppercase the text, then delete its inner spaces.
  4. Trim ordinary spaces, then uppercase the result.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A quantity stored as 0.146 displays as 0.15 after formatting to two decimals. What value does a later calculation use?
  1. 0.15
  2. 0.146
  3. 0.14
  4. 0.1
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A checked helper column contains formulas referring to the raw city column. You need a clean table that will still work after removing that raw column. What should you do?
  1. Copy the formulas into the clean table again.
  2. Format the formula cells as ordinary text.
  3. Paste the checked results as fixed values.
  4. Rename the raw column before deleting it.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A saved query reads a view and uses a separately editable mapping table. Monday and Tuesday runs both log 310 input rows, 8 duplicate copies removed and 302 output rows, but retain different phone numbers. Query history is unchanged; neither raw inputs nor mappings were versioned. What evidence is needed to reproduce Monday’s result?
  1. Monday’s row counts, current map and current raw rows.
  2. Monday’s query text, current map and current row count.
  3. Monday’s totals, current raw rows and latest phone list.
  4. Monday’s raw rows, map version and full survivor rule.
Show answerHide answer

Save this lesson to see this answer.

Set 3: Choose treatments and check transformed data10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A 12-cell age column has two empty cells, three entries of 999 and seven recorded ages. The owner confirms that 999 means "not supplied". How many values are missing after that meaning is recognized?
  1. 2 values
  2. 3 values
  3. 7 values
  4. 5 values
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A survey records job type, and missing commute distances occur more often for remote workers than for on-site workers. The missingness is explained by recorded job type. How is this pattern classified?
  1. Missing completely at random.
  2. Missing at random.
  3. Missing not at random.
  4. A recorded commute of zero.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A service survey has 100 responses. Among 80 known ratings, the sum is 320. Dissatisfied users are more likely to skip the rating. An analyst fills all 20 gaps with the observed mean. What numerical average results, and does it establish the average rating for all users?
  1. 3.2; it establishes the all-user average.
  2. 4; it establishes the all-user average.
  3. 4; the all-user claim remains unsupported.
  4. 5; the all-user claim remains unsupported.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A load contains masses recorded as 1.8 kg, 650 g and 0.9 kg. What is the total mass in kilograms?
  1. 3.35 kg
  2. 652.7 kg
  3. 2.7065 kg
  4. 9.2 kg
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

Two exports were combined. One contains "22/05/2025", and another contains "05/06/2025". There is no source-format metadata yet. What is the sound treatment of the second date?
  1. Convert it to 2025-06-05 because the first date proves the column’s order.
  2. Confirm the second export’s convention before resolving the ambiguous date.
  3. Convert it to 2025-05-06 because the column headings are in English.
  4. Change the display to ISO and accept the date the spreadsheet chooses.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

An account identifier has 18 digits and starts with "00". What import type should preserve its information?
  1. A decimal with two display places.
  2. An integer with a zero-padding format.
  3. A number converted to text afterward.
  4. Text from the start of the import.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A category VLOOKUP with exact match returns #N/A for a new source label. What should happen next?
  1. Review the label and add its verified mapping.
  2. Switch to approximate match for that cell.
  3. Replace every lookup error with the first category.
  4. Replace the error with the nearest mapped label.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A PostgreSQL text column uses exact comparison and contains " queued ", "QUEUED", "queued", "done" and NULL. A query selects DISTINCT LOWER(TRIM(status)) AS status FROM events WHERE status <> 'done'. How many source rows reach SELECT, and how many result rows remain?
  1. 4 source rows; 2 result rows.
  2. 3 source rows; 2 result rows.
  3. 3 source rows; 1 result row.
  4. 2 source rows; 1 result row.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A log states: "Changed customer 672’s city from 'Rmoe' to 'Rome'." What evidence would best support the correction?
  1. The most common city across all customers.
  2. A different customer with a similarly spelled city.
  3. The same customer’s verified source record.
  4. The first city returned by an approximate lookup.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A table has 920 raw rows. A duplicate step removes 26 rows, then validation excludes 9 of the remaining rows. How many rows should the clean table contain?
  1. 903
  2. 885
  3. 894
  4. 955
Show answerHide answer

Save this lesson to see this answer.

Set 4: Diagnose near misses in cleaning workflows10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

An import reports success, but its row count is smaller than the source export and no rows were intentionally excluded. What integrity problem should be investigated first?
  1. An allowed repeated category.
  2. An incomplete data transfer.
  3. A planned number-display change.
  4. A valid unusual order quantity.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A table requires unique IDs, positive whole-number quantities and delivery on or after order. Rows are: R1 (ID A, quantity 2.5, dates valid); R2 (ID A, quantity 3, dates valid); R3 (ID B, quantity NULL, dates valid); R4 (ID C, quantity 1, delivery before order); R5 (ID D, quantity 2, dates valid). How many rows fail at least one rule?
  1. 2 rows
  2. 3 rows
  3. 5 rows
  4. 4 rows
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A shipment key is (shipment_id, item_id), with item IDs standardized by UPPER(TRIM(item_id)). Rows (shipment, item, quantity) are (71, "A", 5), (71, " a ", 5), (71, "B", 8), (71, "A", 6), (72, "C", 4), (72, "C", 4). After DISTINCT on those three cleaned fields, how many rows and conflicting keys remain?
  1. 3 rows; 0 conflicting keys.
  2. 5 rows; 2 conflicting keys.
  3. 4 rows; 1 conflicting key.
  4. 4 rows; 0 conflicting keys.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

An Excel table has cleaned customer keys. What does =COUNTIF($B$2:B2,B2)>1 flag when filled down?
  1. Second and later occurrences of each key.
  2. Every row whose key appears at least once.
  3. Only the first row for each repeated key.
  4. All rows for every key that appears twice.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A mapping table contains the category codes "AA" and "AB". A source value "AC" is absent from the map. Approximate lookup returns "AB", so the error count is zero. What check best exposes the problem?
  1. Trim the mapped outputs and accept nonblank labels.
  2. Check returned labels against the map’s output column.
  3. Compare uppercase codes with approximate matching.
  4. Compare source variants to the map with exact match.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A code layout is region, dash, site, dash, four-digit suffix. Region lengths vary; the suffix always has four digits. A colleague extracts the site with MID(code,4,3). What redesign handles the stated layout?
  1. Locate delimiters for the site and keep the suffix as text.
  2. Keep the fixed start and convert the whole code to a number.
  3. Take the first three characters as the site in every row.
  4. Split at dashes and store the suffix as a number.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A helper formula uses =VLOOKUP(B2,Map!A2:B20,2,FALSE). It works in the first row but loses earlier mapping rows as it is filled down. What needs to change?
  1. Change FALSE to TRUE for every lookup.
  2. Fix the mapping range with absolute references.
  3. Keep B2 fixed while leaving the map range relative.
  4. Expand the map’s last row but leave it relative.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A CASE expression maps amounts above 0 to 'positive', then amounts above 100 to 'large', with ELSE 'check'. For amount 160 it returns 'positive'. How should the logic be corrected if amounts above 100 must be labeled 'large'?
  1. Remove ELSE so the large condition takes priority.
  2. Test above 0 twice before testing above 100.
  3. Test above 100 before the broader above-0 condition.
  4. Add an ELSE label of large after both conditions.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A numeric-text import has no blank cells. COUNT is 74 and COUNTA is 90. After conversion, COUNT is 86; four helpers show "check". What conclusion is supported?
  1. Sixteen entries became numeric; no gaps remain.
  2. Four entries became numeric; twelve were removed.
  3. Twelve entries became numeric; all sixteen were valid.
  4. Twelve entries became numeric; four need review.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A raw amount total is 8,600. Removed rows total 420, and one retained amount is corrected from 35 to 53. No values are filled. What clean total should verification expect?
  1. 8,162
  2. 8,198
  3. 8,180
  4. 8,618
Show answerHide answer

Save this lesson to see this answer.

Set 5: Audit a complete cleaning result10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A PostgreSQL city column contains NULL, an empty string, three ordinary spaces and "Dakar". How many rows match city IS NULL OR TRIM(city) = ''?
  1. 1
  2. 2
  3. 4
  4. 3
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A clean revenue table excludes every order whose optional comment is blank. Amounts and dates were complete for those orders. What integrity issue does this create for monthly revenue?
  1. Only a difference in display formatting.
  2. Only a harmless change to text length.
  3. Loss of relevant orders from the analysis.
  4. Proof that all retained amounts are wrong.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A correction was typed manually into one cell. What record is needed to repeat that exact correction on the same raw data?
  1. The record ID, old value, new value and reason.
  2. The field name, final total and workbook author.
  3. The field name, correction count and date only.
  4. The final value, row count and sheet name only.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A case-sensitive customer ID can validly be "xA" or "Xa" for different people. Rows (ID, amount) are ("xA", 5), ("Xa", 7), ("xA", 5); the two xA rows describe one event. Excel Remove Duplicates on ID leaves only the first row. After correct deduplication, what row count and amount total should verification expect?
  1. 1 row; total 5.
  2. 2 rows; total 12.
  3. 2 rows; total 10.
  4. 3 rows; total 17.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A meter table expects 12 readings. Nine observed readings total 72; three are unavailable. An analyst fills the gaps with the observed mean. What total and description distinguish the recorded information from the estimates?
  1. 96 total, including 24 from estimated readings.
  2. 96 total, all of it directly measured usage.
  3. 72 total, including 24 from observed readings.
  4. 80 total, including 8 from estimated readings.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A SQL Server import has amount_text values NULL, '7.5', 'bad', '0', three ordinary spaces and '19x'. An audit finds NULL results after TRY_CAST(NULLIF(TRIM(amount_text), '') AS DECIMAL(10,2)), but excludes only raw NULLs. How many results are failures of present normalized text, and what inflates the audit?
  1. 3 failures; raw NULL input inflates the count.
  2. 1 failure; numeric zero inflates the count.
  3. 2 failures; space-only input inflates the count.
  4. 2 failures; valid decimal input inflates the count.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A SQLite quantity import contains '0012', '12', '12x', 'abc' and '0'. Valid input must contain decimal digits only. The analyst casts to INTEGER and then counts distinct outputs. How many distinct numeric outputs result, and how many invalid strings have been hidden by coercion?
  1. 3 distinct outputs; 2 invalid strings.
  2. 2 distinct outputs; 1 invalid string.
  3. 3 distinct outputs; 1 invalid string.
  4. 2 distinct outputs; 2 invalid strings.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A spreadsheet cleaning session begins with an unmodified export. What should be preserved before changing cells?
  1. A copy of the helper formulas only.
  2. An untouched copy of the raw data.
  3. Only the first ten visible data rows.
  4. A list of column names and formats.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A table has six rows: IDs 1, 2, 3, 4, 5 and NULL. Quantities are 2, 0, NULL, -1, 5 and 3 in that order. A clean query keeps order_id IS NOT NULL AND quantity > 0. A log counts exclusions only with quantity <= 0. How many excluded rows does that log miss?
  1. 2
  2. 0
  3. 1
  4. 3
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A raw table has 600 rows. Eighteen rows repeat a key and 14 rows fail validation, with 5 rows in both groups. The duplicate step removes all 18 flagged extra copies, including those 5, and validation removes the remaining failed rows. What clean count should be expected?
  1. 568
  2. 578
  3. 573
  4. 587
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

82 Key Terms, each with its definition

A

Absolute reference
An absolute reference fixes a spreadsheet row or column when a formula is copied, keeping a mapping range from shifting accidentally.
The mapping range stays fixed while the source lookup cell changes for each new data row.
Alias
An alias is a name assigned to a SQL result expression, making a transformed output column identifiable without renaming the stored source.
The expression UPPER(TRIM(city)) AS city_clean gives the normalized result a clear alias.

B

Baseline
A baseline is the recorded starting profile against which later counts, ranges, totals and other cleaning results are compared.
The baseline row count helps the reviewer account for every record removed during cleaning.
Boolean
A Boolean is a true-or-false value that can represent the result of a check, such as whether a record violates a data rule.
A spreadsheet duplicate helper returns TRUE when the cleaned key appears more than once.

C

CASE expression
A CASE expression returns the result for its first true condition, with an optional ELSE result for values that match no condition.
A specific status rule is tested before a broader rule so the intended label is selected.
Case-sensitive comparison
A case-sensitive comparison treats uppercase and lowercase letters as potentially different, as spreadsheet EXACT does for text.
EXACT distinguishes "aB" from "Ab" when those codes identify different source records.
CAST
CAST is a SQL operation that requests conversion of an expression to a named type, with failure behavior determined by the database.
The analyst checks source amounts before casting them to a DECIMAL output column.
Changelog
A changelog is a dated list of changes recording the author, affected data, action, count and reason so the work can be reviewed.
The log names both the key columns and keep rule used when duplicate customers were removed.
CLEAN
CLEAN is a spreadsheet function that removes supported nonprinting characters, such as imported line breaks, from a text value.
The analyst checks word boundaries after CLEAN removes an unexpected line break from a label.
Clean data
Clean data is sufficiently correct, complete, consistent and relevant for the particular question an analysis needs to answer.
Orders can be clean for regional sales even if an unused middle-name field still has gaps.
Cleaning summary
A cleaning summary reports the source, period, problems, actions, checks and unresolved gaps that matter to people using the result.
When 88% of customers have known ages, the summary explains that age-based results describe only those customers.
COALESCE
COALESCE is a SQL function that returns its first non-NULL argument, allowing a deliberate fallback for unavailable information.
COALESCE(city, 'Unknown') labels a NULL city without replacing an ordinary nonempty city.
Collation
Collation is a database’s set of text comparison and sorting rules, including whether particular letter-case differences matter.
A case-insensitive collation can group two capitalization variants together in a profile of a city column.
Composite key
A composite key identifies one record through a combination of fields when no single field is sufficient for the row’s meaning.
Shipment ID plus item ID distinguishes two different items within the same shipment.
Concatenation
Concatenation combines text parts into one value, using explicit separators and deliberate handling of optional or missing parts.
The name formula joins first and last name with one space to form a readable display label.
Consistency check
A consistency check tests whether related fields agree with one another according to a rule about their shared meaning.
A delivery date earlier than its order date fails the shipment table’s consistency rule.
Coverage
Coverage describes which required periods, groups, regions or fields remain represented in the data used to answer the question.
A regional comparison lacks required coverage if cleaning excludes all orders from one region.

D

Data integrity
Data integrity is the accuracy, completeness, consistency and trustworthiness of data throughout its collection, storage, transfer and use.
The analyst checks the order export’s integrity before relying on it for a monthly revenue report.
Data profiling
Data profiling is systematic inspection of a table’s structure, values, frequencies, ranges and missing information before changes.
A profile records missing amounts and unexpected status codes before the analyst chooses treatments.
Data transfer
A data transfer moves records between files or systems, where an interrupted or incomplete load can damage the dataset’s completeness.
A source-to-import row-count comparison reveals that part of a file was lost during transfer.
Data type
A data type tells software what kind of value it is handling and which operations, comparisons or conversions apply to that value.
A numeric amount supports arithmetic, while a text identifier should preserve its original digits.
Data validation
Data validation is checking entries against rules that define acceptable values, using the field’s meaning and requirements.
The quantity rule rejects a negative order count even when its cell is neatly formatted.
Date serial number
A date serial number is a numeric representation of a date in a spreadsheet, shown to the reader through a chosen date display format.
Changing a real date’s format reveals its serial number without changing which day it represents.
Deduplication
Deduplication is identifying repeated records and removing or merging extra copies while preserving real distinct events and valid information.
The analyst resolves conflicting phones before deduplication keeps one verified customer record.
Deletion
Deletion as a missing-value treatment excludes incomplete records from an analysis, reducing coverage and potentially changing who is represented.
An order missing its unrecoverable amount is excluded from the known revenue total and reported.
Delimiter
A delimiter is a character or sequence that marks a boundary between text parts, such as a comma between last and first names.
The comma in "Silva, Ana" gives the split a more reliable boundary than the spaces in a full name.
Dirty data
Dirty data is information that is incomplete, incorrect, inconsistent or irrelevant to the analysis it is intended to support.
Repeated order records and several spellings of one city make the export dirty data for city-level sales.
Display format
A display format controls how a stored value appears, without converting its type or changing the value used by calculations.
A value of 0.125 displays as 0.13 while formulas continue to use its full stored precision.
Distinct value
A distinct value is one unique value under a tool’s comparison rules, which can treat capitalization or spacing differently.
A profile of a city column can count "Oslo" and "OSLO" separately even though they name the same city.
Duplicate record
A duplicate record is a row that describes the same real-world entity or event as another row, based on the agreed record key.
A repeated import creates a second copy of an order that should appear once in the sales table.

E

Empty string
An empty string is a text value with no characters, distinct from NULL in databases such as PostgreSQL, MySQL, SQL Server and SQLite.
The import stores an empty string for some blank cities, so an IS NULL check alone misses them.
Exact duplicate
An exact duplicate is a repeated record with matching values in every column being compared, subject to the tool’s matching rules.
Two copies of an imported row share the same key, amount, date and city in the selected columns.
Exact-match lookup
An exact-match lookup returns a mapped result only for a matching lookup value under the function’s comparison rules, exposing missing mappings.
VLOOKUP with FALSE reports an unlisted category for review instead of choosing a nearby label.

F

Filter
A filter retains or excludes records according to a condition, changing which rows appear in the result without necessarily changing stored data.
A WHERE condition returns only orders with a present ID and positive numeric quantity.
FIND
FIND is a spreadsheet function that locates a text fragment’s starting character position, enabling extraction around a delimiter.
LEFT uses the comma position returned by FIND, minus one, to extract a variable-length last name.
Fixed-position extraction
Fixed-position extraction takes characters from known positions and lengths, suitable only when the source layout is consistent.
MID extracts a three-letter site code from a field whose site always starts at character four.
Format check
A format check tests whether a value follows a required text pattern, without establishing that the recorded fact is correct.
A code-length and pattern check can reject "AB12" when the required code has three letters and four digits.
Frequency
A frequency is the number of times a value occurs, useful for spotting category variants, common placeholders and repeated keys.
A frequency list shows that "Unknown" occurs unusually often in one source’s region column.

H

Helper column
A helper column holds a formula or check beside the source values, making an intermediate transformation visible for review.
A city helper column shows each raw city beside its cleaned uppercase label, so the analyst can compare spacing.

I

Imputation
Imputation is filling missing information with an estimated or chosen replacement, which must remain distinguishable from observed data.
Two missing ages are filled with the median and receive flags identifying them as estimates.
ISO 8601 date format
The ISO 8601 year-month-day date format writes a calendar date as YYYY-MM-DD, avoiding the ambiguity of month-first and day-first forms.
The cleaned export writes March 4 as "2025-03-04" so the day and month cannot be confused.
Issue flag
An issue flag marks a record that needs attention while retaining it in the result, unlike a filter that removes the record from view.
A delivery-date flag keeps a flagged order available for review instead of excluding it.

L

List check
A list check tests whether a field contains one of the permitted categories defined by its data rules or mapping standard.
A dropdown limits the status field to the approved labels "open", "shipped" and "returned".
Locale
A locale is a regional setting that helps software interpret conventions such as date order, decimal marks and function separators.
The import locale must match the source separators before "1.234,5" is treated as a number.

M

Mapping table
A mapping table pairs source variants with verified standard values, making category replacements explicit and easy to review.
An exact lookup maps "NORTH" and "North region" to one approved region label.
Mean
A mean is a sum divided by the number of included values; when used to fill gaps, it adds estimates based on the observed data.
Using the observed mean as a fill does not establish what the missing readings actually were.
Median
A median is the middle value of sorted data, or the average of the two middle values, often used as a central fill for skewed data.
A few very large incomes pull the mean upward more strongly than they shift the median.
Missing at random
Missing at random describes gaps whose probability can be explained by other recorded information instead of the absent value itself.
More optional responses missing among older customers creates a pattern linked to recorded age.
Missing completely at random
Missing completely at random describes gaps whose occurrence is unrelated to both observed information and the values that are missing.
A random form-save failure is an example of missingness unrelated to the recorded customer details.
Missing not at random
Missing not at random describes gaps whose occurrence depends on the absent values themselves, potentially distorting the observed results.
Very high earners skipping an income field can leave the known-income average too low.
Missing value
A missing value is information that should be recorded but is absent, possibly represented by a blank, NULL or confirmed placeholder.
The delivery record lacks a required weight, so its missing value must remain visible in the profile.

N

Near duplicate
A near duplicate is a record for the same entity or event with small differences, such as extra spaces or conflicting contact details.
Two customer rows become a candidate pair after their email spacing and case are standardized.
Nonbreaking space
A nonbreaking space is a special space character often copied from web pages that ordinary spreadsheet TRIM does not remove.
SUBSTITUTE replaces CHAR(160) with a normal space before a city helper column applies TRIM.
NULL
NULL is SQL’s marker for an unknown or absent value, tested with IS NULL and treated differently from zero in calculations.
COUNT(amount) skips NULL amounts while COUNT(*) still includes the rows that contain them.
NULLIF
NULLIF is a SQL function that returns NULL when two expressions are equal, and otherwise returns the first expression.
NULLIF(city, 'N/A') turns a confirmed city placeholder into a consistent missing marker.

P

Paste values
Paste values stores computed spreadsheet results as fixed values, removing their dependency on the formulas and input-cell references.
After helper columns are checked, pasting their values makes a clean table independent of deleted raw columns.
Placeholder
A placeholder is a stored stand-in for unavailable information that must be interpreted using the source’s documented meaning.
An age of 999 is counted as missing only after the data owner confirms that placeholder convention.
Presence check
A presence check tests whether a required field has a value, accounting for the forms of missing information the source can store.
The order-ID presence check flags a row that cannot be linked to an identifiable order.

R

Range check
A range check tests whether a value falls within the limits allowed for its field, such as a percentage from 0 to 100.
In a survey of adults, the age range check flags 230 even though it is stored as a valid number.
Raw data
Raw data is the preserved input before cleaning transformations, used as the starting evidence for comparison and repeat runs.
The original export remains on a raw sheet while formulas transform a separate working copy.
Reconciliation
Reconciliation accounts for the difference between starting and final counts or totals through the recorded removals, corrections and fills.
The expected row count subtracts each actual removal once, even when one row had two issues.
Record key
A record key is a column or combination of columns that identifies the entity or event represented by one row of a table.
An order ID identifies orders, while a city name is expected to repeat across many valid orders.
Recovery
Recovery is obtaining a missing field’s true value from reliable evidence or deriving it from other verified values in the same record.
An invoice supplies the order amount that was absent from the export, so no estimate is needed.
Replication
Replication is the copying of data between systems or locations; integrity problems can arise when those copies drift apart.
A corrected customer address in one system can disagree with an older replicated copy in another.
Reproducibility
Reproducibility means the same raw data and recorded rules produce the same clean result, with required mappings and decisions available.
Saved formulas and individually logged corrections let another analyst repeat the cleaning.
Rounding
Rounding replaces a numeric result with a chosen precision, which can change later totals if applied to intermediate values.
Three separately rounded thirds add to 0.99, so the analyst delays rounding until presentation.

S

Safe conversion
A safe conversion returns a missing marker for ordinary conversion failures instead of stopping the query, as TRY_CAST or SAFE_CAST can.
Failed safe casts are counted separately from input values that were already NULL.
Splitting
Splitting divides a combined text value into separate parts using a defined delimiter or layout so each needed field has its own column.
A location field is split into city and country columns before the country codes are validated.
Spot check
A spot check compares selected individual records with the raw data or reliable source, complementing checks across the whole output.
The analyst spot-checks ambiguous dates and identifiers after parsing and type conversion.
SQL dialect
A SQL dialect is a database system’s version of SQL, including its supported function names, syntax and detailed behavior.
The cleaning query uses the dialect’s documented date parser and conversion-failure function.
String
A string is a sequence of text characters, suitable for labels and identifiers even when those characters happen to be digits.
The identifier "00427" stays a string so its leading zeros survive the import.
Substring replacement
A substring replacement changes matching character sequences wherever they occur, potentially altering text inside longer words or codes.
Replacing "NY" everywhere can damage "NYC", so whole-value mappings are safer for category labels.

T

Text standardization
Text standardization makes values with the same intended meaning follow one spacing, spelling and case convention for comparison.
A standard city helper prevents one city’s sales from being divided between accidental label variants.
TRIM
TRIM is a text function that removes end spaces; spreadsheet TRIM also reduces repeated ordinary spaces inside text to one.
SQL TRIM leaves the internal spaces in "Ana Silva", while spreadsheet TRIM reduces that run.
Type check
A type check tests whether a value is stored or entered as the required kind of data, such as a number, date or text identifier.
A numeric type check rejects the word "forty" in an age field before a range check is applied.
Type conversion
Type conversion changes how software represents or treats a value, such as parsing numeric text into a usable numeric quantity.
VALUE converts a verified text amount before the spreadsheet includes it in a numeric total.

U

Uniqueness check
A uniqueness check tests whether each required key occurs only once, according to the key definition and comparison rules.
Grouping a table by order ID after DISTINCT checks whether conflicting copies of an order remain.
Unit conversion
Unit conversion expresses a measurement on a different scale without changing the quantity, so values can share a unit before arithmetic.
Converting 750 g to 0.75 kg lets it be added correctly to the other kilogram measurements.

V

Verification
Verification checks that cleaning resolved the intended problems without introducing errors or losing information needed for the analysis.
The final checks compare clean counts, keys, totals and coverage with the raw profile and log.
Version control
Version control records successive versions of code or other files, helping track and recover changes to a cleaning method over time.
A saved query change is committed with a note explaining the new missing-value treatment.
Version history
Version history preserves earlier states of a file or query so changes can be inspected or an earlier state can be restored.
A workbook stored with version history can be restored to the state before a mistaken replacement.
View
A view is a saved SQL query whose result is evaluated from current source data when read, allowing a cleaning method to be reused.
Reading the clean-order view applies the saved transformations to the latest raw order records.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started