Sub topic 8
Period Counters and Year Flags
This chapter assumes you can write relative and absolute references, and that you have the monthly timeline from the earlier chapters: period start in row 5, period end in row 6, days in row 7, and the fiscal year-end date and fiscal year in rows 9 and 10. It also assumes you know SUMIFS, MOD, YEAR and MONTH.
A timeline holds more than dates. Later formulas need to know which period they are in and whether a year has just started or ended. A period counter numbers each period. A flag is a row of 1s and 0s that marks a condition, such as "this is the last month of the fiscal year". Other rows multiply or test these flags instead of repeating date logic in every formula.
Why counters and flags are separate rows
You can write =IF(MONTH(D6)=$C$3, ...) inside a revenue formula. If you do, the same date logic is copied into dozens of rows, and each copy is a place for an error. Putting the logic in one flag row gives you three benefits:
- One place to audit. You inspect the flag row once, and every formula that uses it is covered.
- Readable formulas.
=D$24*$C$6says "amount on a year-end", while theIF(MONTH(...)version hides that meaning. - Easy totals. You can check a flag row by summing it, as the checks section below shows.
The period counter
The counter is row 8 of the layout from earlier chapters. It starts at 1 and adds 1 in each column:
D8: =1
E8: =D8+1 copy rightThe first cell holds a constant, so everything after it is a formula. This is the one place where the timeline contains a hard-coded number, and it is fine because 1 is a definition, not an assumption.
A counter that does not refer to the previous cell is more robust to column inserts and to a text label sitting in column C:
D8: =COLUMNS($D8:D8) copy rightCOLUMNS($D8:D8) counts the columns from D to the current one, so it returns 1, 2, 3 and so on. The same formula works in every column, which also removes the special first cell.
Do not write =C8+1 in D8 and copy right. If C8 holds a label such as "Period", the first cell returns #VALUE!. If C8 happens to be empty, the counter starts at 1 by accident, and a later edit can change that without anyone noticing.
Fiscal year flags
Rows 9 and 10 already give each month its fiscal year-end date and fiscal year label. Five rows below the revenue row hold the flags. They use the model's input cells (C2 for the start date, C3 for the fiscal year-end month) and rows 5, 6, 8, 9 and 10:
Row 22 (model start flag): D22: =IF(D$8=1,1,0)
Row 23 (fiscal year start flag): D23: =IF(D$5=EOMONTH(D$9,-12)+1,1,0)
Row 24 (fiscal year end flag): D24: =IF(D$6=D$9,1,0)
Row 25 (month in fiscal year): D25: =MOD(MONTH(D$6)-$C$3-1,12)+1
Row 26 (fiscal year index): D26: =D$10-$D$10+1Each formula works as follows.
- Model start flag. It is 1 only in the first column. Use it for one-off items such as opening balances.
- Fiscal year start flag.
EOMONTH(D$9,-12)+1is the first day of the fiscal year that month belongs to. The flag is 1 when the period starts on that day. - Fiscal year end flag. The flag is 1 when the period end equals the fiscal year-end date from row 9. Both are real month-end dates, so the test is an exact match.
- Month in fiscal year. The result runs from 1 to 12, where 1 is the first month after the year end.
MODwraps the negative values that occur before the year-end month. Excel'sMODreturns a result with the sign of the divisor, so it always returns 0 to 11 here. - Fiscal year index. It numbers the fiscal years 1, 2, 3 from the model start. The first value is
D$10-$D$10+1, which is 1.
Here is how the rows behave for a model starting 15-Jan-2025 with June as the fiscal year-end month (C3 = 6):
| Period end | Counter | Fiscal year | Month in FY | FY start flag | FY end flag | FY index |
|---|---|---|---|---|---|---|
| 31-Jan-2025 | 1 | 2025 | 7 | 0 | 0 | 1 |
| 30-Jun-2025 | 6 | 2025 | 12 | 0 | 1 | 1 |
| 31-Jul-2025 | 7 | 2026 | 1 | 1 | 0 | 2 |
| 31-Dec-2025 | 12 | 2026 | 6 | 0 | 0 | 2 |
| 30-Jun-2026 | 18 | 2026 | 12 | 0 | 1 | 2 |
In the first row the FY start flag is 0, even though the model has just started. The fiscal year began on 1-Jul-2024, before the first column, so the model begins part-way through fiscal 2025. That is correct. The first fiscal year is a partial year of six months, and later chapters on annual roll-ups and stub periods rely on this behavior.
Using flags in calculations
A flag turns a date condition into a multiplier. Suppose C6 holds an annual insurance premium paid in the first month of each fiscal year:
D30: =D$23*$C$6The formula returns the premium in months where the fiscal year starts and 0 elsewhere. Because the model starts mid-year, the first fiscal year's premium falls before the first column, so the model never pays it. If you want a payment in the first model month instead, decide that explicitly and combine flags:
D30: =MAX(D$22,D$23)*$C$6MAX is used instead of addition so that a model starting on the first day of a fiscal year does not charge the premium twice. In that case both flags are 1, and a sum would give 2.
Multiplying by a flag and testing it with IF give the same result. Multiplication keeps the formula short and consistent across the row. IF(D$23=1,...) is easier to read when the result is not a number.
Counters that start at an event
Some counters should begin at a date other than the model start, such as the start of operations. Assume an input in C5, the operations start date. This counter returns 0 before operations and then counts 1, 2, 3:
D28: =IF(D$6<$C$5,0,COUNTIFS($D$6:D$6,">="&$C$5))
D29: =IF(D28>0,1,0)COUNTIFS counts the period ends from the first column up to the current one that are on or after the operations date. This counter does not refer to the previous cell, so it has no special first column. Row 29 is the operations flag, which later rows can multiply by. Because the test is against period end dates, the first operating period is the one that contains the start date.
The sign comparison matters. ">="&$C$5 joins the operator to the date's serial number, so the criterion becomes text such as ">=45748", which COUNTIFS reads correctly.
Checks for counters and flags
Add checks beside the continuity and end-of-month checks from the timeline checks chapter:
Counter steps by one (row 13): E13: =E8-D8 -> must equal 1 in every column
Year-end flag count: =SUM(D24:AM24) -> must equal the number of fiscal year ends in the timeline
Start flag count: =SUM(D22:AM22) -> must equal 1For a 36-month model starting in January 2025 with a June year end, the year-end flags must sum to 3 (June 2025, 2026 and 2027). If the sum is 0, the usual cause is a period end that is not a true month end, so row 9 never matches row 6.
Common errors
- Hard-coded year-end months.
=IF(MONTH(D6)=12,1,0)works only for a December year end. Always reference$C$3or the row 9 date. - Mixing text and numbers. A flag that returns
"Yes"orTRUEcannot be multiplied or summed reliably. Return 1 and 0. - Comparing a period start to a month end. The FY start flag compares a first-of-month date to
EOMONTH(...)+1, and the FY end flag compares month ends to month ends. Comparing a start with an end never matches. - Using the calendar year as the fiscal year.
YEAR(D6)is wrong whenever the fiscal year-end month is not 12. Use row 10, which derives the year from the fiscal year-end date. - Forgetting the partial first year. The fiscal year index and the month-in-year row both start part-way through a year when the start date is not in the month after the year end. Check the first column against your expectation.
- Anchoring incorrectly. Use
D$8and$C$3so that the formula can be copied right and down without shifting the row or the input.
Exercise
A model starts on 10-Mar-2025 and has a September fiscal year end (C3 = 9). What does the month-in-fiscal-year formula =MOD(MONTH(D$6)-$C$3-1,12)+1 return in the first column, and is the fiscal year start flag 1 or 0 there?
Show answer
The first period end is 31-Mar-2025, so MONTH(D6) is 3. The formula gives MOD(3-9-1,12)+1 = MOD(-7,12)+1 = 5+1 = 6. March is the sixth month of a fiscal year that starts in October. The fiscal year start flag is 0, because the fiscal year containing March 2025 began on 1-Oct-2024, which is not the period start of 1-Mar-2025. The model therefore starts part-way through fiscal 2025.
Exercise
Write a flag formula for D27 that is 1 in the last month of each calendar quarter, assuming a fiscal year-end month in C3 and the month-in-fiscal-year row in row 25. Which row do you test, and what is the test?
Show answer
Quarters of the fiscal year end in months 3, 6, 9 and 12 of the fiscal year, so test row 25: =IF(MOD(D$25,3)=0,1,0). Using the month in fiscal year rather than MONTH(D6) makes the flag follow the fiscal year-end input. For a June year end it marks September, December, March and June.