Sub topic 12
Common pitfalls and how to debug them
This chapter assumes you can build one-variable and two-variable data tables, that you know what the row and column input cells do, and that you have read about the {=TABLE()} array formula and calculation modes. Here we cover the mistakes that cause most broken tables and a repeatable way to find them.
Data tables fail in two ways. Some fail loudly, with an error message or a refusal to edit. Others fail quietly, and the grid looks plausible but is wrong. The quiet failures cost more, because nobody notices them until someone relies on the numbers.
A debugging routine
Before looking at individual pitfalls, use the same order of checks every time. Most problems show up in the first three steps.
- Check the base case. Compute the grid cell that matches the current inputs minus the model output. The result should be 0.
- Look at the pattern. A table where every cell holds the same number, or where whole rows or columns repeat, points to an input cell problem.
- Confirm the axis mapping. Check which input cell is assigned to the row and which to the column.
- Confirm the calculation mode. Stale values often mean the table has not recalculated.
- Test one grid cell by hand. Type the two axis values into the real inputs, read the model output, and compare it to the grid cell.
The grid is flat
A flat grid, where every cell shows the same value, is the most common failure. It means that changing the input cell had no effect on the output formula.
Typical causes:
- The input cell contains a formula instead of a hardcoded value. Excel overwrites the input cell temporarily with each axis value, so the cell must be a plain input. If the cell holds a formula, the model may depend on a different cell than the one you named.
- The model does not depend on the input cell. For example, the output formula uses a typed number such as
0.065and not a reference toB2. - The output formula in the corner (two-variable) or header cell (one-variable) points to the wrong cell, such as a cell that is not downstream of the input.
- The input cell points to a label or a blank cell next to the real input.
To test for this, change the real input by hand and watch whether the output moves. If the output does not move, the problem is in the model, not in the data table.
B1: 300000
B2: 0.065
B3: 30
B4: =PMT(0.065/12, B3*12, -B1)In the model above, the rate is typed into the PMT formula, so B2 is cosmetic. A table with column input cell B2 returns the same payment in every row. The fix is to reference the input.
B4: =PMT(B2/12, B3*12, -B1)Swapped row and column input cells
In a two-variable table, the row input cell receives the values written across the top row. The column input cell receives the values written down the left column. Many people reverse this because "row" sounds like the thing that runs down the side.
The result is a grid that looks valid. Using the loan example, if you put the row input cell as B2 (rate) while the top row holds years, Excel substitutes 10, 15, 20 and so on as the interest rate. Payments become huge or negative, and the base case check fails.
A rule that helps: the row input cell is for the values in the row of headers. Match by where the values sit, not by what the input is called.
| Axis values sit in | Excel dialog field | Example from the loan model |
|---|---|---|
| Top row (E2:I2, years) | Row input cell | B3 |
| Left column (D3:D7, rates) | Column input cell | B2 |
If the numbers look wrong but nothing is flat, swapped inputs are the first thing to check.
Input cells on a different sheet
Excel requires the input cells to be on the same sheet as the data table. If you pick a cell on another sheet, Excel shows the message "Input cell reference is not valid."
There are two common remedies:
- Move the data table to the sheet that holds the inputs.
- Keep the real inputs on the data table sheet and have the model sheet read them with a normal link, such as
=Inputs!B2pointing the other way. The data table sheet owns the hardcoded value, and the rest of the model follows it.
Do not solve this by linking the input cell on the table sheet to the model's input. If the cell on the table sheet is a formula that reads the original input, the table overwrites the formula cell but the model still reads the original, and the grid goes flat.
The output formula is not linked correctly
In a one-variable column table, the output formula sits one row above and one cell to the right of the first input value. In a row-oriented table, it sits one column to the left and one row below the first value. If the formula is in the wrong place, Excel treats part of your axis as a result and fills the wrong cells.
In a two-variable table, the formula must be in the top-left corner of the selected range. A common error is leaving the corner empty or typing a label there. Then every cell in the grid is 0 or an error.
Also check that the selection includes the headers. If you select only the interior cells (E3:I7), the dialog has nothing to read the axis values from.
Hardcoded numbers on the axis versus links
Axis values can be typed or can be formulas. Formulas are a trap when they refer to the input cell being varied.
For example, suppose D5 holds =B2 so that the middle row always shows the base rate. During calculation Excel substitutes values into B2, which changes D5 while the table is computing. The axis then moves under the table, and results become inconsistent or wrong.
The safe approaches:
- Type the axis values as constants.
- If you want the axis centered on the base case, build it from a separate copy of the base value that is not the input cell. For example, keep a typed base value in a cell outside the model that the axis steps from, and check that it equals the model input with a visible check cell.
Stale values and calculation mode
If the workbook is set to Automatic except for Data Tables, the tables do not recalculate when you edit an input. They recalculate when you press F9. This is a deliberate setting and it is useful for large models, but it makes a table look wrong after you change an assumption.
Symptoms of stale tables:
- The base case check is not 0 even though the setup is right.
- The grid does not change after you edit the model.
- A colleague opens the file and sees different numbers than you saw.
Press F9, then run the base case check again. If the check turns to 0, the table was only stale. If you rely on this setting, put a visible reminder next to each table, such as a note that says "Press F9 to refresh." You can also add the check cell, which will show a nonzero value when the table is out of date.
K2: =E5-B4Editing limits and the TABLE formula
The cells inside the grid hold a single multi-cell array formula, {=TABLE(B3,B2)}. You cannot type this formula yourself, and you cannot change part of the grid.
- Trying to edit one result cell gives the message "Cannot change part of a data table."
- Deleting a single cell in the grid fails for the same reason.
- To change the table, select the entire result range and delete it, then create the table again with the dialog.
- Inserting a row or column inside the grid is blocked. Insert outside the range, or rebuild the table.
The common mistake is pasting values over part of the grid to freeze results. To keep a frozen copy, copy the whole grid and paste it as values in another place. Keep the live table where it is.
Mixed number formats and misleading displays
A table can be right and still be read wrongly. If the axis shows 5% but the cell holds 0.045, rounding hides the real step. A rate displayed as 5% when it is 4.5% leads to a base case that appears missing, even though the check cell shows the truth.
Match the number format of the axis to the precision of the values. Use one decimal place for percentages such as 4.5%. Apply the same format as the input cell so that the base case row visibly matches.
Circular references and iterative calculation
If the model contains a circular reference, such as interest calculated on an average balance, a data table can give unstable results. Each grid cell needs the model to settle, and iterative calculation may stop before it does.
If a table based on a circular model gives odd values:
- Check whether iterative calculation is enabled under Excel's formula options.
- Test a single point by hand and compare it to the grid.
- Consider adding a circuit breaker switch to the model so you can break the loop while debugging.
Quick reference
| Symptom | Likely cause | Fix |
|---|---|---|
| Every cell identical | Output does not depend on input cell, or input cell holds a formula | Link the output to the input, and make the input a hardcoded value |
| Numbers huge or negative | Row and column input cells swapped | Reassign them by where the axis values sit |
| "Input cell reference is not valid" | Input cell on another sheet | Move the table or the inputs to the same sheet |
| All zeros or errors | Corner formula empty or wrong | Put `=B4` in the correct corner cell |
| Base case check not 0 | Stale table, swapped axes, or axis does not contain base values | Press F9, check the mapping, check the axis |
| "Cannot change part of a data table" | Editing one result cell | Clear the whole result range and rebuild |
| Grid shifts or looks inconsistent | Axis values are formulas that depend on the input | Replace them with typed constants |
A worked debugging session
Suppose the loan table shows $1,896.20 in all 25 cells. Follow the routine.
- Base case check:
E5-B4is not 0, because the cells are the same but the model differs by input. - Flat grid: this points to an input problem.
- Change
B2by hand to0.075. The outputB4changes, so the model does respond to the rate. - Look at the table dialog: the column input cell is
B1, the loan amount, instead ofB2. Changing the loan amount to 0.045, 0.055 and so on makes the loan almost zero, but the table shows one number, so check the corner formula too. - Open
D2. It holds=B4, correct. Rebuild the table with the column input set toB2. - Press F9. The check now shows 0.
Each step removed one possible cause, and the actual fault was found by a hand test rather than by guessing.
Exercise
A two-variable table has years (10 to 30) across the top row and rates (4.5% to 8.5%) down the left column. The grid shows payments above $100,000 per month. The corner formula is =B4 and the model is correct. What is the most likely error, and how do you fix it?
Show answer
The row and column input cells are swapped. Excel is substituting the year values (10 to 30) as the interest rate, and the rate values as the term, which produces extreme payments. Delete the result range and rebuild the table with Row input cell = B3 (term, matching the values across the top) and Column input cell = B2 (rate, matching the values down the side). Then confirm that the base case check =E5-B4 returns 0.
Exercise
You set the workbook to Automatic except for Data Tables, then change the loan amount in B1. The data table does not change, but the base case check cell shows a nonzero value. Is the table broken? What do you do?
Show answer
The table is not broken, only stale. With this setting, data tables recalculate only when you press F9. Press F9, and the grid recalculates. The base case check should then return 0. If it does not, continue with the other checks: the input cell mapping, the axis values and the corner formula.