Sub topic 1
What Flags and Switches Do in a Model
A financial model has to answer "what if?" questions without anyone rewriting formulas. A flag or a switch makes that possible. Each is a small cell whose value changes how other formulas behave. This chapter explains what they are, where they sit in a model, and what goes wrong when they are built carelessly. Later chapters build the formulas in detail.
Prerequisites
This chapter assumes you can already do the following:
- Use cell references, including anchored references such as
$C$10and mixed references such asF$5, and copy a formula across a row. - Read a forecast layout with time periods in columns and line items in rows.
- Use basic accounting terms: revenue, pre-tax income, tax, cash, and debt balance.
You do not need to know IF, MIN, or MAX yet. The chapter uses one IF formula and explains it as it appears.
Flags and switches defined
A flag is a cell, usually one of a row of cells, that holds 1 or 0. It answers a yes/no question about a period or an item. Examples: "Is this period inside the project?" and "Has the loan matured yet?" A 1 means yes and a 0 means no.
A switch is a single control cell that the user sets. It chooses between modes of the model, such as base, upside, or downside scenario. Many formulas read the switch, so one change flows through the whole model.
The two ideas often work together. A switch is an input that a person chooses. A flag is usually a calculated result that other formulas multiply or test.
| Feature | Flag | Switch |
|---|---|---|
| Typical values | 1 or 0 | 1, 2, 3 (or 1 and 0) |
| Who sets it | A formula | The user |
| Where it lives | A row across the timeline | One cell on an inputs area |
| Question it answers | "Is this item active in this period?" | "Which case am I running?" |
| Example | Construction-phase flag | Scenario selector |
Why a model needs them
Without flags and switches, an analyst changes a model by editing it. Suppose a bonus is paid only in years 3 to 5. The analyst might type the amount into three cells and leave the others blank. The model then has these problems:
- The row is inconsistent. Some cells are formulas and some are typed numbers, so copying across the row no longer works.
- The assumption is invisible. Nothing on the sheet says why years 3 to 5 were chosen.
- A change is expensive. Moving the bonus to years 4 to 6 means finding and editing cells by hand, and missing one gives a wrong answer with no warning.
- Scenarios cannot be compared. Running the downside case means overwriting inputs and restoring them later.
With a flag, the bonus row has one formula in every column. The start and end years are two input cells. Changing them moves the bonus and nothing else needs touching. This follows the standard modeling principle that a row should hold one consistent formula, and that assumptions belong in labeled input cells.
How controls fit into the model
Controls sit between the inputs and the calculations. The user changes inputs and switches. Flag rows turn those inputs into period-by-period 1/0 values. Calculation rows then use the flags.
A common layout keeps all inputs and switches at the top of one sheet, with labels, units, and a distinct input style such as blue font. Flag rows then sit near the top of the calculation sheet, directly under the timeline. Every line item can refer to a flag on the same column, so a reviewer can trace each one.
A first worked example
Take a timeline with period dates in row 5, starting in column F. The inputs are:
C10: start date of a cost, such as a maintenance contract.C11: end date of the cost.
Row 8 holds the timing flag. In F8 and copied across, enter:
=IF(AND(F$5>=$C$10,F$5<=$C$11),1,0)Read it from the inside out. F$5>=$C$10 asks whether this period's date is on or after the start. F$5<=$C$11 asks whether it is on or before the end. AND returns TRUE only when both are true. IF turns TRUE into 1 and FALSE into 0.
The dollar signs matter. $C$10 and $C$11 are anchored, so every copy points to the same inputs. F$5 anchors the row but not the column, so each column reads its own date.
Row 20 holds the annual cost. To include it only when the contract is active, use the flag:
=F20*F$8If the flag is 1, the result equals the amount. If the flag is 0, the result is 0. If the contract runs from 2027 to 2029 and the timeline runs from 2025 to 2031, the flag row reads like this:
| Period | 2025 | 2026 | 2027 | 2028 | 2029 | 2030 | 2031 |
|---|---|---|---|---|---|---|---|
| Flag (row 8) | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| Cost if active | 0 | 0 | 100 | 100 | 100 | 0 | 0 |
Change C11 to the end of 2030 and the 2030 flag becomes 1. Nothing else needs editing. The next chapters cover how the comparison returns TRUE or FALSE, how IF works in detail, and how to combine flags.
Why 1/0 and not TRUE/FALSE
A comparison such as F$5>=$C$10 returns TRUE or FALSE on its own. Most modelers still convert it to 1 or 0, for these reasons:
- Multiplication is direct.
F20*F$8reads naturally and works the same in every column. - Totals are meaningful. Summing a 1/0 row counts active periods. Excel's SUM ignores TRUE and FALSE values stored in a range, so a TRUE/FALSE row sums to 0.
- Rows are easier to read. A row of 1s and 0s shows a pattern at a glance, and you can apply a number format to it.
- Other software behaves the same. A 1/0 flag exported to another tool is unambiguous.
The one rule is to be consistent. Use 1 and 0 for every flag in the model, never "Yes" and "No" in some places and 1/0 in others. A text flag multiplied by a number returns a #VALUE! error.
Design conventions
A few habits make flags and switches dependable:
- Label each one. Give a flag row a clear name such as "Maintenance contract active (1/0)". A reviewer should know what 1 means without reading the formula.
- Put every threshold in a cell. Dates, caps, rates, and scenario numbers should be inputs. A formula like
=IF(F$5>=DATE(2027,1,1),1,0)hides an assumption in the formula, so avoid it. - Keep one formula per row. The formula in the first column should be identical to the formula in the last when read in relative terms.
- Restrict switch values. Use data validation, for example a list of 1, 2, 3, so nobody can type 4 into a three-scenario switch.
- Show the active choice. Next to a numeric scenario switch, display its name, such as "Base case". People misread bare numbers.
- Keep flags separate from amounts. A flag row holds only 1s and 0s. Do not let it hold a value that is also used as a quantity.
Common errors
Most flag problems come from a small set of mistakes.
- Missing anchors. If
$C$10is written asC10, copying the formula across moves the reference toD10,E10, and so on. The first column looks right and the rest are wrong. Check the flag in the last column, not only the first. - Boundary mistakes. Using
>instead of>=drops the first active period. Using<instead of<=drops the last. Decide whether the start and end dates are included, and test the periods on each side of both. - Date mismatches. If the timeline shows period end dates and the input is a period start date, a one-period shift can result. Use the same date convention for both.
- Hard-coded 1s and 0s. A typed 1 in the middle of a flag row looks the same as a formula result. Select the row and check that each cell contains a formula.
- Errors pass through a zero flag. A flag of 0 does not hide an error. In
=F20*F$8, ifF20is#DIV/0!, the result is still#DIV/0!even when the flag is 0. Fix the source, not the flag. - Switch out of range. If a scenario switch is 4 but only three cases exist, a lookup formula can return an error or, worse, a wrong value. Validation and a visible check cell prevent this.
- Flags that change the balance sheet only. If a flag switches off an expense in the income statement but a related cash or balance item still moves, the balance sheet will not balance. Gate every linked line with the same flag.
What comes next
The rest of this tutorial builds the tools in order. You will learn how comparisons produce TRUE and FALSE, how IF builds a flag, and how timing flags combine with AND, OR, and multiplication. Then MIN and MAX appear as caps and floors, and they are used to handle tax on losses and debt repayment limited by cash and balance. The tutorial ends with a scenario switch built with CHOOSE and a checklist for auditing all of it. Every one of those techniques depends on the idea in this chapter: a control cell, kept visible and consistent, changes how a whole row or model behaves.
Exercises
Exercise
A model has a revenue row where the analyst typed a number into the cells for 2028 to 2030 and left the others blank. Name two problems this creates, and say what a flag-based design would change.
Show answer
The row is inconsistent, because some cells are typed values and others are empty, so one formula cannot be copied across it. The assumption is also hidden, and changing the active years means editing cells by hand with a risk of missing one. With a flag, the row has a single formula such as the amount multiplied by the flag. Start and end dates are labeled input cells, so changing the years means changing two inputs.
Exercise
The flag formula =IF(AND(F$5>=C10,F$5<=C11),1,0) is entered in F8 and copied to G8 and H8. The result is correct in F8 but wrong in G8 and H8. What is the error, and what is the corrected formula?
Show answer
The references to C10 and C11 are not anchored, so they shift to D10 and D11 in column G and E10 and E11 in column H. The corrected formula is =IF(AND(F$5>=$C$10,F$5<=$C$11),1,0).
Exercise
A cost row uses =F20*F$8. In 2026 the flag in F8 is 0, but F20 contains #DIV/0!. What does the result show, and why does it matter?
Show answer
The result is #DIV/0!, because multiplying an error by 0 still returns the error. A zero flag does not hide an error in the amount row. The source of the error has to be fixed, otherwise it will spread into totals and statements.