Creating a Recursive Model

Models involving different time periods often require using the ending value of one time period as the starting value for the next. The calculations describing these situations have two characteristics:

Recursive models require that the columns are produced in sequential order, one by one. In nonrecursive models, all of the columns can be produced simultaneously. Schematically, these patterns are shown as follows.

recursive model

FML automatically switches to sequential order as soon as either of the two modeling conditions requiring the switch is recognized (either reuse of labels by different rows, or forward reference to a label in a calculation).


Top of page

Example: Creating a Recursive Model

The following example illustrates recursive models. Note that one year of ENDCASH becomes the next year of STARTING CASH.

DEFINE FILE REGION
CUR_YR=E_ACTUAL;
LAST_YR=.831*CUR_YR;
NEXT_YR=1.2297*CUR_YR;
END
 
TABLE FILE REGION
SUM LAST_YR CUR_YR NEXT_YR
FOR ACCOUNT
10$$ AS 'STARTING CASH' LABEL STCASH        OVER
RECAP STCASH(2,*) = ENDCASH(*-1);           OVER
" "                                         OVER
3000 AS 'SALES' LABEL SLS                   OVER
3100 AS 'COST' LABEL COST                   OVER
BAR                                         OVER
RECAP PROFIT/I5C = SLS - COST;              OVER
" "                                         OVER
RECAP ENDCASH/I5C = STCASH + PROFIT;
END

The output is shown as follows.

                      LAST_YR          CUR_YR         NEXT_YR
                      -------          ------         -------
STARTING CASH        7,903.64        9,024.00       10,374.00
                                                             
SALES                4,986.00        6,000.00        7,378.20
COST                 3,864.15        4,650.00        5,718.10
               --------------  --------------  --------------
PROFIT                  1,121           1,350           1,660
ENDCASH                 9,024          10,374          12,034

Information Builders