Topic 3 · Google Spreadsheets  ›  Week 5

Google Sheets — Clean the Data, then Pie & Scatter

Hands-on labs begin. This week you meet our course dataset — MYMart, a Malaysian retail chain — clean it, then build your first two charts in Google Sheets.

By the end of this week you can…

  • Import a dataset into Google Sheets and find your way around the interface.
  • Spot and fix common data-quality problems — inconsistent text, stray spaces, duplicates, errors.
  • Build and format a pie chart and a scatter plot with the Chart editor.
  • Judge whether the chart you built actually fits the message (back to Chapter 2).

5.1  Getting into Google Sheets

Google Sheets is a free spreadsheet that runs in your browser — no install. Sign in with a Google account, then open a blank sheet at sheets.new.

  1. Go to sheets.new (or Google Drive → New ▸ Google Sheets).
  2. Import the data: File ▸ Import ▸ Upload → choose MYMart_Sales_RAW.xlsxInsert new sheet(s).
  3. Rename the tab (double-click it) to Raw so you know it's the untouched data.

5.2  Meet the MYMart data

Before charting, understand what you're holding (Chapter 1 §1.4). MYMart is a fictional Malaysian retail chain. Each row is one sale line; the columns describe the sale.

Column groupColumnsGood for…
WhenDate, Month, Quarterline charts (trends)
WhereState, City, Branchbar charts, maps
WhatProduct Category, Productpie, stacked/clustered bars
WhoGender, Age, Membershiphistogram, boxplot
How muchQuantity, Unit Price, Discount, Cost, Sales, Profit, Ratingscatter, distributions
Tip: the full column meanings are on the Data Dictionary tab inside the CLEAN file — keep it open while you work.

5.3  Clean it first — this data is messy on purpose

Real data is never tidy, and MYMart RAW is no exception. If you chart it as-is, "Selangor" splits into a dozen fake states and your totals are wrong. Fix these five problems in order:

Why cleaning matters — the "State" column
✗ Raw — 40+ "states"

SELANGOR Selangorr selangor Selangor  K.Lumpur KualaLumpur N9 N.Sembilan Malacca Pulau Pinang Johorr

✓ Cleaned — 11 states

Johor · Kedah · Kuala Lumpur · Melaka · Negeri Sembilan · Pahang · Penang · Perak · Sabah · Sarawak · Selangor

A chart groups by exact text — so “SELANGOR”, “selangor” and “Selangorr” become three different bars until you standardise them.

Follow these seven steps in order. (Column letters below match the file: State = E, Gender = I, Membership = K, Category = L, Quantity = N, Unit Price = O, Sales = R, Payment Method = T.)

Step 1 · Work on a copy — never the raw

  1. Right-click the Raw tab → Duplicate → rename the copy Clean. You'll do all cleaning on Clean and keep Raw untouched as a safety net.
  2. Freeze the header so it stays visible while you scroll: View ▸ Freeze ▸ 1 row.

Step 2 · Remove stray spaces

  1. Select everything (Ctrl/⌘ + A) → Data ▸ Data cleanup ▸ Trim whitespace. This strips the leading/trailing spaces in values like "Chocolate Bar   " and " LED Bulb ".
  2. For double spaces inside text, open Edit ▸ Find and replace, Find " " (two spaces), Replace with " " (one space) → Replace all. Repeat until it finds none.

Step 3 · Standardise the text columns

A chart groups by exact text, so SELANGOR, selangor and Selangorr must all become one value. Two techniques:

  1. Casing only (Gender, Membership). These are just wrong capitalisation. In an empty column type =PROPER(TRIM(I2)) and fill down (PROPER turns MALE / male / mALEMale). Then copy the helper column → Edit ▸ Paste special ▸ Values only back over the original, and delete the helper. Do the same for Membership (=PROPER(TRIM(K2)) → Gold / Silver / Non-Member).
  2. Casing + misspellings + nicknames (State, Payment Method). Use Edit ▸ Find and replace with Match case OFF and Match entire cell contents ON, replacing each bad value with the correct one. For State, map every variant to the 11 standard names:
    SELANGOR / selangor / Selangorr → Selangor · K.Lumpur / KualaLumpur / KUALA LUMPUR → Kuala Lumpur · Johorr / JOHOR → Johor · Pulau Pinang / PENANG → Penang · Malacca / MELAKA → Melaka · N9 / N.Sembilan / NEGERI SEMBILAN → Negeri Sembilan · plus the plain UPPER/lowercase versions of Perak, Sabah, Sarawak, Kedah, Pahang.
    For Payment Method, collapse everything to the five real methods: E-wALLET (tNg) / e-wallet (tng) → e-Wallet (TnG), DUITNOW QR → DuitNow QR, DEBIT CARD → Debit Card, CREDIT CARD → Credit Card, CASH → Cash.
  3. Faster for many corrections (optional). On a new tab make a two-column Corrections table (wrong → right). In a helper column use =IFERROR(VLOOKUP(TRIM(E2), Corrections!$A:$B, 2, FALSE), E2), fill down, then paste the result back as values. This scales better than dozens of find-and-replaces.

Step 4 · Remove duplicate rows

  1. Each sale should appear once. Select all the data → Data ▸ Data cleanup ▸ Remove duplicates (keep Data has header row ticked). This drops the ~150 repeated rows.
  2. To confirm by ID: in a helper column type =COUNTIF($A:$A, A2) — any result greater than 1 is a repeated InvoiceID. Check those, then delete the helper column.

Step 5 · Delete impossible values (data errors)

  1. Turn on a filter: Data ▸ Create a filter.
  2. Click the filter arrow on QuantitySort A→Z. Negative quantities (e.g. −10) rise to the top — you can't sell −10 units. Select those rows → right-click → Delete rows.
  3. Do the same for Unit Price — negative prices (e.g. −68.72) are errors; delete them.
  4. Sort Unit Price Z→A and eyeball the very top for absurd outliers (e.g. 2220) — verify it's real before keeping it.

Step 6 · Decide what to do with blanks

  1. Never fill a blank with 0 — that invents data and will lie in your chart.
  2. Blank Age, City, CustomerID, Rating — leave them. Charts simply skip blank rows.
  3. Blank Unit Price — you need it for the scatter, so filter Unit Price → (Blanks) → delete those rows (or exclude them when you chart).

Step 7 · Final check

  1. Confirm State is fixed: in a spare cell type =COUNTUNIQUE(E2:E) — it should read 11. (Or drop a quick pivot of State to eyeball the list.)
  2. Turn the filter off (Data ▸ Remove filter) and save. This Clean sheet is now the single source for every chart in Weeks 5–7 — and again in Power BI.
Golden rule: clean once, then chart everything from the clean copy. You'll reuse this exact clean data for the rest of Weeks 5–7 (and again in Power BI).
● Try it · Clean a column

Take the Payment Method column in the RAW file — it has values like E-wALLET (tNg), e-wallet (tng) , DUITNOW QR. Standardise it down to the five real methods. How many distinct values did you start with, and end with?

● Session 1 recap

A chart is only as good as the data under it. Before plotting: duplicate the sheet, trim spaces, standardise text, remove duplicates, and delete impossible values. Then never touch the raw copy again.

5.4  The Chart editor

Every chart in Sheets is made the same way: select the data you want to show, then Insert ▸ Chart. The Chart editor opens on the right, with two tabs — Setup (chart type & data) and Customize (titles, colours, labels).

5.5  Pie chart — sales share by product category

A pie shows parts of a whole, so first we need one number per category. Build a small summary table, then chart it.

  1. On a blank area, make a 2-column summary: Product Category and Total Sales. Use =SUMIF(Clean!L:L, "Fashion", Clean!R:R) for each category (column L = Category, R = Sales), or faster — insert a Pivot table (Insert ▸ Pivot table): Rows = Product Category, Values = SUM of Sales.
  2. Select the summary (both columns) → Insert ▸ Chart → in Setup choose Pie chart.
  3. In Customize ▸ Pie chart, turn on Slice label → Percentage, add a clear Chart title: “MYMart sales share by category”.
Expected result — sales share by category
  • Fashion — 22.4%
  • Baby & Kids — 21.1%
  • Electronics & Acc. — 18.9%
  • Groceries — 10.5%
  • Household — 8.7%
  • Beauty & Health — 7.9%
  • Snacks — 5.3%
  • Beverages — 5.1%

Fashion and Baby & Kids together are ~44% of sales.

● Watch out — design judgement (Chapter 2)

This pie has 8 slices — beyond the ≤6 rule. The three smallest (Beverages, Snacks, Beauty) are hard to rank by eye. For a report you'd either group the small ones into “Others”, or show this as a bar chart. Building the chart is a tool skill; choosing the right one is the Chapter 2 skill — always ask both.

5.6  Scatter plot — is quantity linked to sales?

A scatter needs two numeric columns. Let's ask: do sales with more units sold bring in more money? Plot Quantity (x) against Sales (y).

  1. Select the Quantity and Sales columns (for a clear demo, use a sample of ~100 rows so the cloud isn't too dense).
  2. Insert ▸ ChartSetupScatter chart.
  3. In Customize ▸ Series, tick Trend line to show the direction. Label both axes with units (RM).
Expected result — Quantity vs Sales (positive relationship)
Quantity (units) → Sales (RM) ↑

The cloud rises left-to-right — more units sold generally means higher sales (a positive relationship, as expected).

● Practice — apply your skills

Open Week 5 Practice.xlsx:

  • Practice 1 · Pie — a student's monthly budget (Food, Transport, Phone…). Build a pie of spending share. Which category is biggest? Is a pie a good choice here (≤6 slices)?
  • Practice 2 · Scatter — 18 small shops' ad spend vs weekly sales. Build a scatter with a trend line. Positive, negative, or none?

Key terms & definitions

Data cleaning
Fixing inconsistent text, stray spaces, duplicates and errors so charts summarise correctly.
Trim whitespace
Removing leading/trailing spaces so "Cash " and "Cash" count as one.
Find & replace
Bulk-standardising text values (e.g. every "SELANGOR" → "Selangor").
Pivot table
A tool that summarises rows into group totals (e.g. total Sales per Category) — the fastest way to feed a chart.
Chart editor
The Sheets panel (Setup + Customize) where you pick the chart type and format it.
Trend line
A line added to a scatter that shows the overall direction of the relationship.

✅ Quick self-check

1. Why must you standardise the State column before charting?

2. What's the fastest way to get one total per category for a pie?

3. Your pie has 8 slices. The best response is…

Week 6 →