Sub topic 1
Structuring data so formulas can find it
SUMIFS, XLOOKUP, and INDEX with MATCH all assume the data is laid out in a predictable way. Most "broken" lookups in financial models come from the layout, not from the formula. This chapter covers the layout rules that make the later formulas simple and reliable.
Prerequisites
You should be comfortable with the following:
- Entering formulas and moving around a workbook.
- Relative and absolute references (
A5,$A5,C$3,$F$2). Chapter 3 revisits these in the context of lookups. - A simple financial statement or budget layout, with accounts down the side and periods across the top.
- Excel tables or named ranges. This is helpful, but the examples use plain ranges.
Two kinds of sheets
A model works best when it separates sheets by what they do.
- Data sheets hold raw records, such as a ledger export or a list of assumptions. They are tall, plain, and not meant to be read as a report.
- Report sheets hold the statement layout, such as a monthly P&L or a budget. They contain formulas that pull from the data sheets.
Formulas on report sheets can only find what the data sheets expose. If the data sheet is hard to search, every formula becomes complicated.
The flat table rule
A flat table has these properties:
- One header row at the top, with one name per column.
- One record per row. A row is one transaction, one assumption, or one rate.
- One kind of value per column. A column does not mix dates and notes, or numbers and text.
- No blank rows or columns inside the table.
- No subtotals, titles, or notes inside the table.
Here is a small ledger laid out this way. The Data sheet has the columns Entry ID, Account, Category, Date, Description, and Amount.
| Entry ID | Account | Category | Date | Description | Amount |
|---|---|---|---|---|---|
| 1001 | Software | Opex - IT | 2026-01-05 | Annual licence | 1200.00 |
| 1002 | Salaries | Opex - People | 2026-01-31 | January payroll | 18500.00 |
| 1003 | Product sales | Revenue | 2026-02-03 | Invoice 7731 | 42000.00 |
| 1004 | Software | Opex - IT | 2026-02-14 | Cloud hosting | 640.50 |
These columns match the examples in the later chapters. Account is column B, Category is column C, Date is column D, and Amount is column F. Notice that the account name is repeated on every row. That repetition is intentional. A formula can filter on a value only if the value is present on the row.
What breaks the flat table
Each of these habits looks tidy to a human reader but defeats a formula.
- Merged cells. Only the top-left cell of a merged block holds a value. The other rows look blank to SUMIFS and MATCH.
- Grouped labels. A layout that writes "Opex" once and leaves the cells below it empty has the same problem. Fill the label into every row.
- Subtotal rows inside the data. A SUMIFS that totals a whole account will count the subtotal as well as the lines it summarizes, which double counts.
- Months as columns in the ledger. A ledger with one column per month cannot be filtered by date. Keep one Date column and let the report sheet spread the months across.
Unique keys
A key is the value you search for. In the ledger, Account is a key you total by. In an assumptions list, the key is the label that names each input.
The two uses have different rules:
- In a ledger, keys repeat. SUMIFS is designed to add up every row that matches.
- In a lookup table, keys must be unique. A lookup returns one value, so if a key appears twice, the formula returns the first match and ignores the second. It gives no warning.
Here is an assumptions table laid out for lookups. The key is in column B and the value is in column C, with a unit column for readers.
| Key | Value | Unit |
|---|---|---|
| Tax rate | 0.25 | percent |
| Inflation | 0.03 | percent |
| Opening headcount | 14 | people |
| Days in debtors | 45 | days |
Give each key one spelling and use it everywhere. "Tax rate" and "Tax Rate" match in Excel because lookups ignore case. "Tax rate" and "Tax rate " (with a trailing space) do not match.
Types must agree
Excel compares values by type. The number 2026 and the text "2026" are different, even though they look identical on screen. Three problems come up repeatedly:
- Dates stored as text. A date criterion such as
">="&C$3compares numbers. A text date is skipped, and the row silently drops out of the total. - Numbers stored as text. These are often left-aligned and show a green corner mark. SUMIFS ignores them in the sum range.
- Stray spaces and non-breaking spaces. These are common in exports from accounting systems. Two keys that look equal are not equal.
You can test the data directly. This formula counts rows in the Date column that hold something other than a real date or number:
=SUMPRODUCT((Data!$D$2:$D$5000<>"")*(NOT(ISNUMBER(Data!$D$2:$D$5000))))This one counts account names that have leading or trailing spaces:
=SUMPRODUCT(--(Data!$B$2:$B$5000<>TRIM(Data!$B$2:$B$5000)))Both should return 0. Put them on a checks sheet so a bad import is visible the moment it arrives. If either returns a positive number, clean the data at the source before you change any report formula.
Checking that keys are unique
A uniqueness check on the assumptions list counts how often each key appears. This formula returns 1 when the key in $A5 is present exactly once:
=COUNTIF(Assumptions!$B$3:$B$12, $A5)A result of 0 means the key is missing. A result of 2 or more means it is duplicated. To check the whole list at once, count the keys that appear more than once:
=SUMPRODUCT(--(COUNTIF(Assumptions!$B$3:$B$12, Assumptions!$B$3:$B$12)>1))The result should be 0. Chapter 15 builds these into a full set of checks. For now, the point is that uniqueness is something you verify, not something you assume.
Bounded ranges and tables
Later formulas refer to ranges such as Data!$F$2:$F$5000. This is a bounded range. It stops at row 5000 and starts at row 2, so it skips the header. Bounded ranges have three advantages over whole-column references:
- They are faster to calculate on large workbooks.
- They make the intended data area visible when someone audits the formula.
- They never include the header or a total row placed under the data by mistake.
The cost is that data past row 5000 is silently ignored. Two protections work well. You can choose a bound well above the expected size and add a reconciliation check against the source, as Chapter 15 shows. Or you can convert the data to an Excel table (Ctrl+T), which grows automatically and lets formulas refer to columns by name, such as Ledger[Amount].
Tables are useful but not required. This tutorial uses plain bounded ranges so that each formula can be read without extra context. The layout rules above apply either way.
A short layout checklist
Before you write any lookup or SUMIFS formula, confirm the following:
- The data sits in a flat table with one header row.
- Every row has a value in every key column.
- Lookup keys are unique, and ledger keys are consistently spelled.
- Dates are real dates and amounts are real numbers.
- The ranges in your formulas cover the whole table and no more.
Exercise
A colleague's ledger has the account name "Software" written once at the top of a group of 20 rows, with the cells below it left empty. They then use SUMIFS to total the Software account and get only the amount from the first row. What is wrong, and what is the fix?
Show answer
SUMIFS compares each row's own cell to the criterion, and the 19 empty cells do not equal "Software", so those rows are skipped. The ledger is not a flat table. The fix is to fill "Software" into every row of the Account column (unmerge cells if needed), so each record carries its own key.
Exercise
Your assumptions list contains the key "Tax rate" in B3 and again in B9, with different values. An XLOOKUP for "Tax rate" returns a value without an error. Why is this a risk, and which formula would reveal the problem?
Show answer
An exact-match lookup returns the first match and ignores later ones, so the model silently uses the B3 value even if B9 was the intended update. Use =COUNTIF(Assumptions!$B$3:$B$12, $A5) for the key. A result of 2 shows the duplicate, so you can remove or rename one entry.