Sub topic 3
Building a Flag with IF
Assume you know cell references, relative and absolute references, and how to copy formulas across a forecast row. You should also be familiar with time periods arranged in columns and with basic terms such as revenue, cash, tax, and debt.
A flag is a control value that tells a model whether a condition is true. Most financial models use 1 for on and 0 for off. A switch is a related control that chooses between alternatives, such as base, upside, and downside cases. These controls let the model respond to inputs instead of relying on manually changed formulas.
Comparisons return TRUE or FALSE
A comparison tests two values. Excel returns the logical result TRUE or FALSE.
| Comparison | Meaning |
|---|---|
| `F5>=C10` | The value in F5 is greater than or equal to C10 |
| `F5<=C11` | The value in F5 is less than or equal to C11 |
| `F5=C10` | The two values are equal |
| `F5<>C10` | The two values are different |
For example, if F5 contains 31-Dec-2026 and C10 contains 30-Jun-2026, the comparison F5>=C10 returns TRUE. Dates are stored as numbers in Excel, so date comparisons work in the same way as numeric comparisons.
A comparison by itself returns a logical value. A model often needs a numeric value instead, because later formulas can multiply by 1 or 0. The IF function converts a condition into the required result.
Building a 1/0 flag with IF
The general form is:
=IF(condition,value_if_true,value_if_false)This formula evaluates the condition. If the condition is true, Excel returns the second argument. Otherwise, it returns the third argument.
=IF(F$5>=$C$10,1,0)This formula returns 1 when the period date in row 5 is on or after the start date in C10. It returns 0 before the start date.
The dollar signs are important when you copy the formula across the timeline:
F$5keeps the date row fixed while the column changes from F to G, H, and so on.$C$10keeps both the column and row fixed, so every period refers to the same input cell.
A flag can then control another line item:
=F20*F$8If the flag in F8 is 1, the line item in F20 remains active. If the flag is 0, the result is zero. This separates the calculation from the decision about when the calculation applies.
Timing flags with a start and end date
To turn an item on between two dates, both conditions must be true. Use AND inside IF:
=IF(AND(F$5>=$C$10,F$5<=$C$11),1,0)The formula returns 1 when the period date falls between the start date in C10 and the end date in C11, including both boundary dates.
The timing logic is easier to inspect when you show it as a separate row:
If the end date is optional, a direct AND formula may return zero when the end-date cell is blank. Decide explicitly whether a blank means “no end date” and write the formula to match that policy. Do not leave the behavior to chance.
Combining conditions
Use OR when any one condition should activate the flag:
=IF(OR(F20>0,F21>0),1,0)Use AND when every condition must be satisfied. Multiplication can also combine numeric flags:
=F8*F9The result is 1 only when both flags equal 1. If either flag is 0, the result is 0. This is useful when separate rows represent timing, eligibility, and management approval.
Review the flag before using it
Check the following points:
- Confirm that the first active period and last active period are correct.
- Copy the formula across enough periods to expose the transitions.
- Check that anchored references point to the intended inputs.
- Avoid hard-coded dates or thresholds inside repeated formulas when the value belongs in an input cell.
- Test boundary dates, blank inputs, negative values, and unexpected text.
- Make sure downstream formulas use the flag consistently.
A flag is a small formula with a large effect. A reversed comparison or misplaced dollar sign can change an entire forecast.
Exercise
Cell C10 contains 1-Jan-2026, C11 contains 31-Mar-2026, and row 5 contains monthly period-end dates. Write a formula for F8 that returns 1 only for periods from January through March 2026 and can be copied across.
Show answer
=IF(AND(F$5>=$C$10,F$5<=$C$11),1,0)