Functions
Signatures show argument names, not types. key, numeratorKey, and denominatorKey are strings that identify a financial line. year, period, offset, window, and digits are integers. Conditions and midYear are Booleans, and all other arguments are decimals unless noted as overloaded below.
Functions return decimals unless stated otherwise. A missing value is distinct from zero.
Financial Series
Section titled “Financial Series”| Function | Result |
|---|---|
Val(key, year, period) | The line’s value at the given period. |
YOY(key, year, period) | Change from the previous year: (current - previous) / abs(previous). |
QOQ(key, year, period) | Period-over-period change from the previous year: (current - previous) / abs(previous). |
LAG(key, offset, year, period) | The value offset years before the given period. |
MOVAVG(key, window, year) | Average of the available values over window years, ending with and including year. |
H_GROWTH(key, window) | Average year-over-year growth over window years, counting back from the last reported year. |
H_RATIO(numeratorKey, denominatorKey, window) | sum(numerator) / sum(denominator) over window years, counting back from the last reported year. |
Val(Args.RevenueKey, Cur.Year, 4)YOY(Args.RevenueKey, Cur.Year, 4)QOQ(Args.RevenueKey, Cur.Year, 4)LAG(Args.RevenueKey, 2, Cur.Year, 4)MOVAVG(Args.RevenueKey, 3, Cur.Year)H_GROWTH(Args.RevenueKey, 3)H_RATIO(Args.CogsKey, Args.RevenueKey, 3)For annual models, pass 4 as the period argument of Val, YOY, QOQ, and LAG.
| Function | Missing-value and edge behavior |
|---|---|
YOY, QOQ | Return a rate, so 0.10 means 10%. Missing if either value is missing or the previous value is zero. The denominator is the absolute previous value, even when that value is negative. |
LAG | Missing if offset is zero or negative, or if a period input is missing. |
MOVAVG | Skips missing values, so [100, missing, 120, 140] gives 120. Missing if no values are available, window is zero or negative, or an integer input is missing. |
H_GROWTH | Skips years where either value is missing or the previous value is zero. Returns 0 if no valid years remain. Missing if key is blank or window is zero or negative. |
H_RATIO | Skips years where either value is missing. Returns 1 if no valid years remain or the denominator sum is zero. Missing if a key is blank or window is zero or negative. |
Missing Values and Division
Section titled “Missing Values and Division”| Function | Supported types | Result |
|---|---|---|
COALESCE(a, b) | (Decimal, Decimal) -> Decimal(Integer, Integer) -> Integer | a if present, otherwise b. Missing if both are missing. |
NULLIF(a, b) | (Decimal, Decimal) -> Decimal(Integer, Integer) -> Integer | Missing if both are present and equal, otherwise a. |
SAFE_DIV(numerator, denominator) | (Decimal, Decimal) -> Decimal | The quotient. Missing if either input is missing or the denominator is zero. |
COALESCE(AssumptionCurve.RevenueGrowth, 0.02)MOVAVG(Args.RevenueKey, COALESCE(Args.WindowOverride, 3), Cur.Year)SAFE_DIV(100, 0)NULLIF(0, 0)The last two examples return missing.
Conditions
Section titled “Conditions”IIF is overloaded across decimals, integers, strings, and Booleans, selecting the matching signature from the argument types. Legacy aliases IIF_INT and IIF_STR remain supported for backward compatibility.
| Function | Supported types | Result |
|---|---|---|
IIF(condition, a, b) | (Boolean, Decimal, Decimal) -> Decimal(Boolean, Integer, Integer) -> Integer(Boolean, String, String) -> String(Boolean, Boolean, Boolean) -> Boolean | a when condition is true, otherwise b. |
IIF_INT(condition, a, b) | (Boolean, Integer, Integer) -> Integer | Alias for the integer overload of IIF. |
IIF_STR(condition, a, b) | (Boolean, String, String) -> String | Alias for the string overload of IIF. |
IIF(Args.UseGrowth, this.PrevY * 1.05, this.PrevY)LAG(Args.RevenueKey, IIF(Args.UseTwoYearLag, 2, 1), Cur.Year, 4)Val(IIF(Args.UseAlternative, Args.AlternativeKey, Args.RevenueKey), Cur.Year, 4)Both branches are always evaluated, so an error in the unused branch still stops the calculation.
Mathematics and Scaling
Section titled “Mathematics and Scaling”ABS, MIN, MAX, and CLAMP support both decimal and integer arguments, returning the same type as their inputs. All other functions in this group accept and return decimals.
| Function | Supported types | Result |
|---|---|---|
ABS(x) | Decimal -> DecimalInteger -> Integer | Absolute value. |
MIN(a, b) | (Decimal, Decimal) -> Decimal(Integer, Integer) -> Integer | The smaller value. |
MAX(a, b) | (Decimal, Decimal) -> Decimal(Integer, Integer) -> Integer | The larger value. |
CLAMP(x, lower, upper) | (Decimal, Decimal, Decimal) -> Decimal(Integer, Integer, Integer) -> Integer | x restricted to the bounds. Reversed bounds are swapped. |
ROUND(x, digits) | (Decimal, Integer) -> Decimal | x rounded to digits decimal places, from 0 to 28. Midpoints round away from zero. |
SQRT(x) | Decimal -> Decimal | Square root of x. |
POW(base, power) | (Decimal, Decimal) -> Decimal | base raised to power. |
M(x) | Decimal -> Decimal | x multiplied by 1,000,000. |
K(x) | Decimal -> Decimal | x multiplied by 1,000. |
Each function returns missing if any input is missing. ROUND also returns missing for an invalid precision. SQRT returns missing when x is negative, and POW returns missing if the result is undefined (such as a negative base with a fractional power) or overflows.
| Example | Result |
|---|---|
ABS(-125) | 125 |
MIN(0.05, 0.08) | 0.05 |
MOVAVG(Args.RevenueKey, MIN(Args.RequestedWindow, 5), Cur.Year) | Moving average over at most 5 years |
MAX(-10, 0) | 0 |
CLAMP(0.35, 0, 0.20) | 0.20 |
ROUND(125.555, 2) | 125.56 |
ROUND(-1.25, 1) | -1.3 |
SQRT(16) | 4 |
POW(2, 3) | 8 |
POW(16, 0.5) | 4 |
M(1.5) | 1500000 |
K(250) | 250000 |
Discounting and Valuation
Section titled “Discounting and Valuation”Discounting functions accept decimal cash flows, rates, and growth inputs (and integer periods/years) and return decimals.
| Function | Result |
|---|---|
PV(cashFlow, rate, periods) | Present value of a single cash flow: cashFlow / (1 + rate)^periods. |
NPV(key, rate, startYear, endYear) | Sum of discounted annual values of key from startYear through endYear, discounted back to startYear - 1. |
NPV(key, rate, startYear, endYear, midYear) | Same as NPV, using mid-year discounting (t - 0.5) when midYear is true. |
PV_PERPETUITY(cashFlow, rate, growth, periods) | Present value of a growing perpetuity: (cashFlow * (1 + growth)) / ((rate - growth) * (1 + rate)^periods). |
PV(120, 0.085, 3)NPV(Args.FcffKey, Args.Wacc, 2026, 2030)NPV(Args.FcffKey, Args.Wacc, 2026, 2030, true)PV_PERPETUITY(Val(Args.FcffKey, 2030, 4), Args.Wacc, 0.025, 5)