BUS 120 · Spreadsheets and Business Data
Tables, Sorting and Filtering
Arrange data in clean rows, turn it into an Excel table, then sort and filter it without scrambling your records.
Key takeaways
- Clean data has one header row, one kind of fact per column, one record per row and no blank rows inside.
- An Excel table grows with your data, copies formulas down and lets formulas refer to columns by name.
- Sorting changes the order of rows, so whole rows must always move together.
- Filtering only hides rows, which means a plain SUM still includes them while SUBTOTAL can skip them.
- Check row counts and totals before and after you rearrange anything important.
Jonah manages the books for a made-up community theater. One afternoon he wants to see the biggest expenses first. He highlights the Amount column and clicks the sort button. The amounts line up beautifully, largest to smallest.
The names, dates and descriptions did not move. The $2,000 lighting bill now says it was paid for cookies. Jonah stares at the screen, then reaches very quickly for Undo.
Sorting and filtering are among the most useful things a spreadsheet does. They are also easy ways to scramble a ledger. The difference comes down to how the data is arranged before you touch a button.
The shape of good data
Think of a list as a stack of index cards. Each card is one record: one payment, one sale or one employee. Each line on the card is a field: date, payee, amount.
In a spreadsheet, each record gets a row and each field gets a column. The top row holds the headers, short names for the fields. Follow a few rules.
- Use exactly one header row, with a different name over every column.
- Put one fact in one cell. "Paint, $40, March 3" in a single cell is three facts wearing one coat.
- Keep each column to one type. Dates in the date column, numbers in the amount column.
- Leave no blank rows or columns inside the list.
- Keep totals and notes outside the list, or let a table's total row handle them.
- Avoid merged cells. They look tidy and break sorting.
Make it clean first. Make it pretty somewhere else.
This style is sometimes called a flat list. It can look repetitive, with the same department written on dozens of rows. That repetition is what lets the computer group, filter and summarize.
Why the report is not the data
Beginners often build one sheet that tries to be both the records and the report. It has a title, a blank line, a section called March, some rows, a subtotal, another blank line and a section called April. A person can read it. A computer cannot tell which rows are payments and which are decorations.
Keep two layers. One tab holds the plain list, with nothing but headers and records. Other tabs read from that list and present it nicely. You can then change the report as often as you like without touching a single record.
If you receive a file in the messy style, resist the urge to sort it. First copy it. Then remove the title rows and subtotals from the copy, fill in the month or department on every row and check that your cleaned total still matches the original total.
Making it an Excel table
In Excel, click any cell in your list and choose Insert, then Table, or press Ctrl+T on Windows. Confirm that your data has headers. The block becomes a table, an object that Excel treats as one unit. Other programs offer similar features under their own names and menus.
You gain several things.
- Filter buttons appear on each header.
- When you type in the row just below, the table expands to include it.
- A formula typed in one cell of an empty column fills the whole column. This is a calculated column.
- A total row can be switched on at the bottom.
- Formulas can use column names, called structured references.
Suppose Jonah names his table Spending. Instead of =SUM(D2:D500), he can write:
=SUM(Spending[Amount]) That reads like English, and it still works when the list grows from 6 rows to 600. Inside the table, a formula such as =[@Amount]*0.5 means "half of the amount on this same row." The @ sign points to the current row.
Sorting without scrambling
Sorting rearranges rows by the values in one or more columns. Text sorts alphabetically. Numbers sort by size. Dates sort from oldest to newest or the reverse.
In a table, use the button on a header. The whole row moves as one. Outside a table, click a single cell inside the data before sorting, or select every column. If Excel asks whether to expand the selection, the answer is almost always yes.
You can sort by several levels. Choose Data, then Sort, and add levels. Sort first by department, and within each department by amount from largest to smallest.
Before an important sort, add an ID column numbered 1, 2, 3 and so on. If something goes wrong, sorting by ID restores the original order.
A worked example: the theater's spending
Here are Jonah's six payments. The theater and the figures are invented.
| ID | Date | Payee | Department | Amount |
|---|---|---|---|---|
| 1 | Mar 2 | Bright Lights Co. | Tech | 2000 |
| 2 | Mar 5 | Corner Bakery | Lobby | 150 |
| 3 | Mar 9 | Fabric Barn | Costumes | 420 |
| 4 | Mar 14 | Corner Bakery | Lobby | 180 |
| 5 | Mar 20 | Wire and Plug | Tech | 350 |
| 6 | Mar 27 | Fabric Barn | Costumes | 300 |
The total is 2000 + 150 + 420 + 180 + 350 + 300 = 3,400.
Step 1: sort by amount, largest first. The order of IDs becomes 1, 3, 5, 6, 4, 2. The total is still 3,400, because sorting moves rows and changes no values.
Step 2: filter to the Tech department. Rows 1 and 5 remain visible. The other four are hidden.
Step 3: add it up. Below the table, Jonah compares two formulas.
=SUM(Spending[Amount]) → 3,400 (counts hidden rows too)
=SUBTOTAL(109, Spending[Amount]) → 2,350 (visible rows only) Check: 2000 + 350 = 2,350. The first number in SUBTOTAL picks the job. The code 109 means "sum, ignoring hidden rows," and 103 counts visible non-empty cells. The table's total row uses SUBTOTAL for you.
2,350 + 720 + 330 = 3,400, which matches the full list. Hypothetical example: the numbers are made up to show the method, not a quote or an average.
Step 4: prove it ties. Costumes is 420 + 300 = 720. Lobby is 150 + 180 = 330. Then 2,350 + 720 + 330 = 3,400. Every payment landed in one department, and none was counted twice.
That last step is a control total, a figure you already trust that the new view must agree with. Accountants use this habit constantly, for example when they check that the detail behind an account matches the balance in the ledger.
Filtering: look closer without deleting
Filtering shows only the rows that meet your conditions. The rest are hidden, not removed. Row numbers skip and often change color as a hint.
You can filter by checking values in a list, by text such as "contains Bakery," by number such as "greater than 300" or by date range. Filters on several columns work together, like AND from logical and text functions. Filtering Department to Tech and Amount to over 500 leaves only the $2,000 bill.
Excel also offers slicers, clickable buttons that filter a table and show which choices are active.
For a filtered view that lives in its own spot, recent versions of Excel include a FILTER function. For example, =FILTER(Spending, Spending[Department]="Tech") spills the matching rows onto the sheet and updates when the data changes. Older versions do not have it.
The common mistake: forgetting the filter is on
Jonah filters to Tech, goes to lunch and comes back. He selects what he sees, copies it into an email and calls it "March spending." It reports $2,350. The real figure is $3,400.
Filters stay on when you save the file, so the next person may open a partial view without realizing it. Before you report a number, look for the filter symbol on the headers and for gaps in the row numbers. Better yet, label your report with what it includes, such as "Tech department only."
A related trap is editing while filtered. Pasting a block of values into filtered rows can land data in hidden rows you did not intend to change. Clear the filter before bulk edits.
Questions a clean list can answer
Once the list is clean, many questions take seconds. Who did the theater pay most often? Filter the payee column, or count with =COUNTIFS(Spending[Payee], "Fabric Barn"), which returns 2. What was the largest single payment? =MAX(Spending[Amount]) returns 2,000. What was the average? 3,400 ÷ 6 is about 566.67.
Notice how far that average sits from a typical payment. Five of the six payments are under 500. One large lighting bill pulls the average up. Sorting by amount shows this at once, which is why a quick sort is often the first thing an accountant does with unfamiliar data. Unusual items float to the top, where you can ask about them.
Keeping duplicates and typos out
A list is only useful if its entries are consistent. "Costume," "Costumes" and "costumes " may be treated as different groups.
Data validation limits what a cell will accept. You can offer a drop-down list of departments, or require a date in the date column. Jonah keeps his department names on a separate tab and points the drop-down at them.
Excel can also remove duplicates with a button. Be careful. Two identical $150 bakery payments might be a double entry, or two real purchases. Investigate before deleting, and keep a copy of the original.
With a clean table in hand, you are ready for pivot tables, which summarize thousands of rows in a few clicks.
Words to know
Record all the facts about one item or event, usually one row.
Field one kind of fact, usually one column with its own header.
Table an Excel object that treats a block of data as one growing unit with headers.
Structured reference a formula reference that uses table and column names instead of cell addresses.
Sorting rearranging rows by the values in chosen columns.
Filtering hiding rows that do not meet your conditions without deleting them.
Control total a trusted figure that a new view or copy of the data must agree with.
Check yourself
- Name three rules for laying out a clean list.
- What is the danger of sorting just one column of a list?
- With the theater filtered to Costumes, what do SUM and SUBTOTAL with code 109 return for Amount?
- How many rows remain if you filter the theater list to amounts over 300?
- Why is =SUM(Spending[Amount]) better than =SUM(E2:E7) for a growing list?
- Why should you investigate before removing duplicate rows?
Show the answers
- Any three of: one header row, one fact per cell, one type per column, no blank rows, no merged cells and totals kept apart.
- The values move but the rest of each row stays, so facts from different records get mixed together.
- SUM returns 3,400 because it includes hidden rows, while SUBTOTAL returns 420 + 300 = 720.
- Three rows remain: 2000, 420 and 350, since 300 is not greater than 300.
- The structured reference expands with the table, so new rows are included without editing the formula.
- Identical rows may be real separate transactions, so deleting them could remove true records.