Skip to content

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.

Every reference to a financial value answers two questions: which line, and which year.

ReferenceWhich line?Which year?
this.PrevYThe line whose expression is being calculatedThe previous year
Cur.<line path>Another line, named by its pathThe year being calculated
PrevY.<line path>Another line, named by its pathThe 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 calculatedCurPrevY
202720272026
202820282027
202920292028

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.Assets

this 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.1

If the line’s previous value was 100, the result is 110.

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:

  1. Operating profit depends on revenue and operating expenses.
  2. Operating expenses depend on revenue and an expense ratio.
  3. Revenue depends on last year’s revenue and a growth assumption.
  4. 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.

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.

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.