What You Will Learn
- How to sort data correctly (single column and multiple columns)
- How to filter data without losing information
- The "filter view" vs "delete rows" distinction
- The most common beginner mistake that destroys datasets
Why This Topic Matters
Sorting and filtering are the two operations you will do in almost every spreadsheet session. They look trivial — and they are — but done wrong they silently break your data. A bad sort detaches names from amounts. A bad filter permanently deletes rows you needed. This lesson teaches the safe, repeatable way.
The Sample Dataset
We will use this small orders table throughout. You can re-create it in any spreadsheet:
| A: order_id | B: customer | C: city | D: amount | E: status |
|---|---|---|---|---|
| 001 | Anita | Mumbai | 500 | paid |
| 002 | Ravi | Chennai | 1200 | pending |
| 003 | Mira | Kolkata | 750 | paid |
| 004 | Anita | Mumbai | 300 | refunded |
| 005 | Sam | Chennai | 900 | paid |
Sorting in Excel — The Right Way
Single-column sort
- Click anywhere inside the data (e.g., cell C2).
- Go to Data → Sort (or use the A→Z / Z→A buttons on the toolbar).
- Choose Sort by = City, order = A to Z.
- Check "My data has headers" so the header row stays put.
- Click OK.
Excel will sort the entire table by city, keeping each row intact. Mumbai rows will group together, then Chennai, then Kolkata.
Sort by multiple columns
Suppose you want to sort by city (A→Z) and then, within each city, by amount (largest first). Use Data → Sort and add two levels:
- Level 1: Sort by
city, A to Z. - Level 2: Then by
amount, Largest to Smallest.
Result: Anita's two Mumbai orders will appear together, with the larger one (₹500) above the smaller one (₹300).
Sort by custom order
Sometimes alphabetical is not what you want. For status, you might want: paid → pending → refunded. Use Order: Custom List in the Sort dialog and type the order you want. This is useful for any categorical column with a meaningful non-alphabetical order.
Filtering in Excel — The Right Way
Apply the filter
- Click anywhere inside the data.
- Go to Data → Filter (or Ctrl+Shift+L).
- Dropdown arrows appear on each header cell.
Use the filter
Click the dropdown on city. You will see a list of all cities with checkboxes. Uncheck "Select All", then check only "Mumbai". Click OK. Only Mumbai rows are now visible; the others are hidden, not deleted.
Filter by amount
Click the dropdown on amount → Number Filters → Greater Than. Enter 700. Now only rows where amount > 700 are visible: Ravi's ₹1200, Mira's ₹750, Sam's ₹900.
Combine filters
Filters stack. If you filter city = Mumbai AND amount > 700, you get only Mumbai rows with amount > 700. With our dataset, that gives zero rows — Anita's Mumbai orders are ₹500 and ₹300. This zero-row result is itself useful: it tells you Mumbai has no large orders in this dataset.
The Most Common Beginner Mistake
Sorting a single column without selecting the whole table.
If you click on column D (amount) and press the A→Z sort button, Excel will ask: "Expand the selection?" If you click "Sort only the current column", Excel will sort only the amount column — leaving customer, city, and status in their original rows. Now Anita's ₹500 is next to a different customer's name. The data is corrupted.
Always choose "Expand the selection". A row is one record; sorting must move the whole row together.
Filter View vs Delete Rows
Beginners sometimes delete rows they want to exclude from analysis. This destroys data. The right approach:
- Apply a filter to hide unwanted rows.
- Copy the visible rows to a new sheet if you need a separate view.
- Keep the original sheet intact.
This way you can always undo or change the filter. Deleted data cannot be recovered.
Google Sheets Differences
The same operations work in Google Sheets with minor naming differences:
- Data → Create a filter instead of Data → Filter.
- Sort range instead of Sort dialog.
- Sheets has a "Filter view" option that lets multiple users filter the same sheet independently without affecting each other's view. Use it when collaborating.
Common Mistakes
- Forgetting "My data has headers". The header row gets sorted into the data.
- Sorting one column only. Rows become internally inconsistent.
- Deleting instead of filtering. Data is lost permanently.
- Filtering on formatted display value. If a number is stored as text, number filters will not work. Fix the type first.
- Trusting the filter visually. Always check the row numbers to confirm what is hidden.
Practical Exercise (10 minutes)
- Create the sample dataset above in a fresh spreadsheet.
- Sort by amount, largest to smallest. Confirm Anita's ₹500 row stays together with her name and city.
- Filter to show only "paid" orders. Confirm there are 3 visible rows.
- Add a second filter: paid orders with amount > 600. Confirm only Mira (₹750) and Sam (₹900) remain.
- Clear the filters. Confirm all 5 rows return.
Mini Challenge
Download any open CSV — for example, a small dataset from Kaggle's public datasets. Sort it by two columns (e.g., category then price). Filter it to show only one category with price above the median. Save the result as a new sheet. You have just done your first real data-cleaning operation.
Key Takeaways
- Always check "My data has headers" before sorting.
- Always sort the whole row together — never a single column.
- Filters hide rows; they do not delete them. Row numbers will skip.
- Never delete rows to exclude them — filter instead, and keep the original intact.
- Filters stack. Combining filters across columns is the core of spreadsheet analysis.
Previously learned: Phase 2 (lessons 07–11) taught you how analysts think.
Today: You learned the first practical spreadsheet skill — sorting and filtering safely.
Next: Lesson 13 covers the Excel formulas every analyst should know: SUM, AVERAGE, COUNT, IF, and friends.
FAQ
Why does Excel sometimes sort numbers as text?
Because the numbers are actually stored as text. This happens when data is imported from CSV and Excel mis-detects the type, or when numbers have leading apostrophes. Fix by selecting the column, using Data → Text to Columns, and choosing "General" format. The numbers will become real numbers and sort correctly.
What is the difference between Sort and Filter?
Sort rearranges the order of rows. Filter hides some rows. Sort changes the sequence; filter changes the visibility. You can do both at once: filter to one city, then sort the visible rows by amount.
Comments
Comments
Post a Comment