How Expressions Are Calculated
DeepFinance calculates a model one year at a time, starting with the first year of its calculation range. For each year, it evaluates the expressions needed to produce the line values.
In this page, the year being calculated means whichever historical or forecast year DeepFinance is working on, such as 2027. It is not the current calendar year.
Choosing the Line and the Year
Section titled “Choosing the Line and the Year”Every reference to a financial value answers two questions: which line, and which year.
| Reference | Which line? | Which year? |
|---|---|---|
this.PrevY | The line whose expression is being calculated | The previous year |
Cur.<line path> | Another line, named by its path | The year being calculated |
PrevY.<line path> | Another line, named by its path | The previous year |
The placeholders describe what goes there; they are not text to type. Use the exact line path that your model provides.
| Year being calculated | Cur | PrevY |
|---|---|---|
| 2027 | 2027 | 2026 |
| 2028 | 2028 | 2027 |
| 2029 | 2029 | 2028 |
Cur is a period, not the current line. Reading another line through Cur is the normal way to connect calculations within the same year. For example, where the model exposes the assets path, this expression calculates the annual change in assets:
Cur.BalanceSheet.Assets - PrevY.BalanceSheet.Assetsthis always follows the line being calculated. On a revenue line it refers to revenue, and on an expense line it refers to that expense. The same growth expression can therefore be reused on several lines without changes:
this.PrevY * 1.1If the line’s previous value was 100, the result is 110.
How Related Lines Are Calculated
Section titled “How Related Lines Are Calculated”When an expression needs another line’s value, DeepFinance obtains it first. If that line also needs calculating, its own expression is evaluated, and so on down the chain until every input is available.
For example:
- Operating profit depends on revenue and operating expenses.
- Operating expenses depend on revenue and an expense ratio.
- Revenue depends on last year’s revenue and a growth assumption.
- DeepFinance calculates revenue first, then expenses, then operating profit.
You only describe the relationships. You do not need to arrange lines in calculation order. Where a line has an actual value for the year, that value is used and its expression is not evaluated.
Circular References
Section titled “Circular References”A circular reference occurs when a value needs itself before it can be calculated, either directly or through other lines. The calculation then has no starting point, and DeepFinance reports an error.
Suppose revenue is defined as operating profit plus expenses, and operating profit is defined as revenue minus expenses, both for the same year. Each line waits for the other, so neither can be calculated. The fix is to give one line an independent driver, for example by growing revenue from last year’s revenue.
Referring to an earlier year of the same line, as this.PrevY does, is not circular, because it asks for a different period. A lookup function such as Val or MOVAVG can still create a loop if it reads the current year of the line being calculated. End such lookups at the previous year when the relationship requires it.
The First Calculated Year
Section titled “The First Calculated Year”A growth expression needs a previous value to start from. At the beginning of a model, or when a line is new, that value may not exist. An initial value expression supplies it; see Line Expressions and Timing.
