Sub topic 2
Combining Flags with AND, OR, and Multiplication
This chapter assumes you can write IF formulas, compare values with >, <, and =, use absolute references such as $C$3, and copy formulas across period columns. It also assumes you know basic terms like pre-tax income, cash, and debt balance.
Combining flags with AND, OR, and multiplication
A single comparison often does not capture a rule. A line item may need to be active only after a launch date and before a sunset date. AND returns TRUE only when every condition is TRUE. OR returns TRUE when at least one condition is TRUE. Wrap either one in IF to produce a 1/0 flag:
=IF(AND(F$5>=$C$10,F$5<=$C$11),1,0)Multiplying 1/0 flags is an alternative. The product is 1 only when every flag is 1, and it is often easier to audit than nested IFs:
=F$8*F$9> Note: the callout below is the only block for this note.
MIN and MAX basics
MIN returns the smallest of its arguments. MAX returns the largest. Both accept any number of arguments, so MIN(5,3,8) returns 3 and MAX(5,3,8) returns 8.
Replacing simple IF logic with MIN and MAX
Many IF formulas only choose between a calculated value and a limit. The following two formulas return the same result:
=IF(F20*$C$3>$C$4,$C$4,F20*$C$3)
=MIN(F20*$C$3,$C$4)The MIN version is shorter and has fewer places for an error.
| Goal | IF version | MIN or MAX version |
|---|---|---|
| Cap a bonus at a maximum | `=IF(F20*$C$3>$C$4,$C$4,F20*$C$3)` | `=MIN(F20*$C$3,$C$4)` |
| Floor a value at zero | `=IF(F30<0,0,F30)` | `=MAX(0,F30)` |
Floors and caps in practice
A floor sets a minimum, and a cap sets a maximum. Tax that ignores losses uses a floor of zero:
=MAX(0,F30)*$C$5Debt repayment needs both a floor and a cap. Repayment cannot be negative, and it cannot exceed the opening balance:
=MIN(F41,MAX(0,F38))Exercise
A loan's opening balance is in F41 and cash available is in F38. Which formula gives the repayment, and why does the order of MIN and MAX matter?
Show answer
=MIN(F41,MAX(0,F38)). MAX first removes negative cash. MIN then caps the result at the balance. Reversing the order would allow a negative cash amount to pass through the cap unchanged.