Home / Knowledge work / Spreadsheets
Tables, sorting, filtering and core formulas
Set up clean data in Google Sheets or Excel, sort and filter it safely, and use the handful of formulas that do most everyday work.
Beginner · 11 min read · Updated December 3, 2026
Most spreadsheet trouble starts with messy data, not hard formulas. If your data is laid out cleanly, sorting, filtering and math become easy. This lesson works the same way in Google Sheets and Microsoft Excel. Where they differ, we say so.
Lay out data as a clean table
A clean table follows a few rules:
- One header row at the top with a short, clear name for each column: Date, Customer, Item, Qty, Price.
- One row per record. One sale, one job, one invoice per row.
- One kind of data per column. Dates only in the Date column. Numbers only in Qty. Do not type "5 boxes" in a number column; type 5 and put "boxes" in the header.
- No blank rows or columns inside the data. Blanks break sorting and filtering.
- No merged cells in the data. They look tidy but break almost everything.
- Totals go somewhere else, not mixed into the rows.
Turn it into a real table
Both apps can mark a range as a table, which keeps formatting, sorting and formulas tidy as you add rows.
- Excel: click any cell in the data and press Ctrl+T (Cmd+T on a Mac), or choose Insert, then Table. Check "My table has headers".
- Google Sheets: click a cell in the data and choose Format, then Convert to table (or press Ctrl+Alt+T, Cmd+Option+T on a Mac).
Tables grow automatically when you add a row at the bottom, and formulas copy down by themselves.
Sort safely
Sorting puts rows in order, like newest date first or largest amount first.
The big danger: sorting one column by itself. If you sort only the Price column, prices get separated from their customers and your data is ruined. Always sort the whole table.
- In a table, click the arrow on a column header and choose Sort A to Z or Z to A.
- For two levels, like Customer then Date, use Data, then Sort (Excel) or Data, then Sort range, then Advanced (Sheets) and add a second sort rule.
If you make a mistake, undo right away with Ctrl+Z (Cmd+Z on a Mac). Sheets also keeps full version history under File, then Version history, and Excel files saved in OneDrive or SharePoint have version history too.
Filter to see only what you need
Filtering hides rows you do not want to see without deleting them. Click the arrow on a header and pick values, like only "Lopez", or a condition, like Price greater than 20.
In Google Sheets, a filter view lets you filter for yourself without changing what your coworkers see in a shared sheet. Excel has a similar feature called Sheet View, under the View tab. Use these when others are working in the same file.
Clear filters when you are done, so the next person does not think rows are missing.
The core formulas
Every formula starts with an equals sign. Cell references like B2 point to a cell. A range like B2:B100 means every cell from B2 to B100.
| Formula | What it does | Example |
|---|---|---|
=SUM(range) | Adds numbers | =SUM(E2:E100) |
=AVERAGE(range) | Average of numbers | =AVERAGE(E2:E100) |
=COUNT(range) | Counts cells with numbers | =COUNT(D2:D100) |
=COUNTA(range) | Counts cells that are not empty | =COUNTA(B2:B100) |
=MIN and =MAX | Smallest and largest | =MAX(E2:E100) |
=IF(test, yes, no) | Chooses one of two results | =IF(D2>=10, "Bulk", "Normal") |
=SUMIF(range, rule, sum_range) | Adds only matching rows | =SUMIF(B2:B100, "Lopez", E2:E100) |
=COUNTIF(range, rule) | Counts only matching rows | =COUNTIF(C2:C100, "Valve") |
Basic math works too: =D2*E2 multiplies quantity by price to get a line total.
Copying formulas and the dollar sign
When you copy a formula down, the cell references move with it. =D2*E2 in row 2 becomes =D3*E3 in row 3. That is usually what you want.
Sometimes you want one reference to stay fixed, like a tax rate in cell H1. Add dollar signs: =D2*E2*$H$1. The $ locks the column and row so it does not move when copied. Press F4 (Windows) or Cmd+T (Mac Excel) while editing to add the dollar signs for you.
Add a line total column
In F2 type=D2*E2and press Enter.Fill it down
Double-click the small square at the bottom right of the cell. In a table it fills automatically.Total it
Below or beside the table, type=SUM(F2:F100).Total one customer
Type=SUMIF(B2:B100, "Lopez", F2:F100).Check it
Filter for Lopez and look at the sum shown in the status bar at the bottom of the window. The two numbers should match.
Get help writing formulas
Both apps now include AI help. Excel has Copilot and Google Sheets has Gemini, depending on your plan. You can also ask Claude or ChatGPT: "In Google Sheets, write a formula that totals column F only for rows where column B is Lopez." Always test the formula on a few rows you can check by hand.
Common mistakes
- Numbers stored as text (they line up on the left and will not add). In Excel, select the cells, click the small warning icon and choose Convert to Number. In Sheets, select the column and choose Format, then Number, then Number. If that does not work, retype them.
- Sorting one column instead of the whole table
- Blank rows that cut the table in two
- Typing totals by hand instead of using a formula
- Forgetting to clear a filter and thinking data is gone