Documentation_
Welcome to the interactive Sumvela Engine documentation. Explore functions below, read their use-cases, and test them live.
Advanced Concepts
Global Implicit Binding
Advanced ConceptsExplanation
Any undefined variable used in the global scope is automatically treated as an Input. You do not need to explicitly declare `name: Input("name")` unless you want to alias it.
EXAMPLEImplicit vs Explicit
Comparison of explicit declaration vs implicit binding
Relative Indexing
Advanced ConceptsExplanation
Access the value of a variable from a previous iteration (or relative position) using bracket syntax. Equivalent to using OFFSET but more concise.
EXAMPLEPrevious Period Reference
Calculate growth based on the previous value
Dynamic Indexing
Advanced ConceptsExplanation
Access array elements using a dynamic index expression. Extremely useful when you need to look up values based on calculation results or the current iteration index.
EXAMPLECopying Arrays
Use the current index to map values from one array to another
Implicit Properties
Advanced ConceptsExplanation
Access properties of objects within a generic LAMBDA parameter or implicitly bound variable without needing specific Param declarations.
EXAMPLEScan with Implicit Property
Accessing properties on the item directly
EXAMPLEImplicit Context in MAP
Arrays in the expression implicitly align with the loop
Aggregation
SUM
AggregationExplanation
Calculates the sum of all numeric values. Automatically flattens arrays and handles multiple arguments.
EXAMPLETotal Revenue
Calculate total revenue from multiple product lines
EXAMPLEAnnual Expenses
Sum all monthly operating expenses for the year
AVERAGE
AggregationExplanation
Calculates the arithmetic mean of all numeric values.
EXAMPLEAverage Deal Size
Calculate average contract value across all deals
EXAMPLEMonthly Average Revenue
Find the average monthly recurring revenue (MRR)
MIN
AggregationExplanation
Returns the smallest value from the provided arguments.
EXAMPLEMinimum Cash Balance
Find the lowest cash balance point in projections
MAX
AggregationExplanation
Returns the largest value from the provided arguments.
EXAMPLEPeak Revenue Quarter
Identify the highest quarterly revenue
COUNT
AggregationExplanation
Returns the number of elements in an array. Input must be an array.
EXAMPLENumber of Active Contracts
Count total contracts for capacity planning
Array Operations
MAP
Array OperationsExplanation
Input must be an array. Transforms an array by applying a calculation to each element. Supports both scalar and object arrays with LAMBDAs for explicit parameter naming. Can be used inline within other expressions.
EXAMPLEScalar Array with LAMBDA
Apply calculation to simple numeric arrays
EXAMPLEObject Array with Multi-Parameter LAMBDA
Calculate revenue from product data with multiple properties
EXAMPLEInline Nested MAP
Use MAP within other expressions without assignment
EXAMPLEComplex Financial Model
Multi-period revenue projections with growth rates
SEQUENCE
Array OperationsExplanation
Generates a list of sequential numbers. Useful for creating time series or index arrays.
EXAMPLEBasic Sequence
Generate numbers 1 to 5
EXAMPLECustom Range
Generate years
SCAN
Array OperationsExplanation
Input must be an array. Scans an array and returns an array of accumulated results. The accumulator carries over logic from one iteration to the next.
EXAMPLECumulative Cash Flow
Calculate running total of monthly cash flows
EXAMPLECompound Growth Projection
Project revenue with year-over-year growth
EXAMPLEObject Array with Implicit Logic
Accumulate values using properties directly from the array objects
LAMBDA
Array OperationsExplanation
Defines an anonymous function with named parameters for use in MAP and SCAN. Parameter names automatically bind to object properties in object arrays, or represent the scalar value in scalar arrays.
EXAMPLEScalar Array LAMBDA
Single parameter binds to the array element value
EXAMPLEObject Array LAMBDA
Multiple parameters bind to object properties by name
EXAMPLEComplex Logic
Use full expressions within LAMBDA
EXAMPLESCAN with Accumulator
Two parameters: accumulator and current item
EXAMPLEExtract Attribute (Column)
Extract a specific column from a table input by ignoring the row parameter and accessing the column name directly.
OFFSET
Array OperationsExplanation
Input must be an array. Access array elements relative to the current iteration index. Used within MAP/SCAN to reference previous or future values. Negative steps look backward, positive look forward.
EXAMPLERevenue Growth Rate
Calculate month-over-month revenue growth
EXAMPLEInventory Replenishment
Calculate inventory to order based on previous consumption
Context Functions
INDEX
Context FunctionsExplanation
Returns the current iteration index (0-based) when used without arguments in a MAP/SCAN. With arguments, retrieves the value at the specified position (1-based, like Excel). Note: Bracket notation array[index] uses 0-based indexing.
EXAMPLEGet Specific Year (1-Based)
Retrieve Year 5 revenue using Excel-style 1-based indexing
EXAMPLELast Element Using COUNT
Get the last element using 1-based COUNT
EXAMPLETime-Based Escalation (0-Based INDEX())
Apply annual price increases using INDEX() without arguments (0-based)
CURRENT
Context FunctionsExplanation
Returns the current item being processed in a MAP/SCAN iteration. Access object properties using Param declarations or LAMBDA parameters.
EXAMPLEVariance Analysis
Calculate variance between actual and budget
Data Binding
INPUT
Data BindingExplanation
Binds a variable to external input data. key is optional; if omitted, the variable name is used as the key. Supports scalars, arrays, and objects.
EXAMPLEFinancial Statement Inputs
Import key financial metrics from external systems
EXAMPLECustomer Cohort Data
Analyze customer lifetime value by cohort
CONST
Data BindingExplanation
Defines a constant value (number or string). Used for fixed assumptions and parameters.
EXAMPLEFinancial Assumptions
Define standard rates and multipliers
PARAM
Data BindingExplanation
Declares a parameter that will be bound from the context during MAP iteration. Used to access properties of objects in arrays (Legacy). Prefer using LAMBDA parameters.
EXAMPLEInvoice Line Items
Calculate invoice totals from line items
OBJECT
Data BindingExplanation
Creates an object/dictionary from key-value pairs. Useful for building structured context data.
EXAMPLEFinancial Metrics Object
Build a metrics object for analysis
Date Functions
DATE
Date FunctionsExplanation
Creates a valid date object from year, month, and day numbers.
EXAMPLECreate Date
Construct a specific date
EOMONTH
Date FunctionsExplanation
Returns the last day of the month, a specified number of months before or after start_date.
EXAMPLENext Month End
Get end of next month
EDATE
Date FunctionsExplanation
Returns a date that is the indicated number of months before or after the start date.
EXAMPLE3 Month Anniversary
Add 3 months
YEARFRAC
Date FunctionsExplanation
Calculates the fraction of the year represented by the number of whole days between two dates. Uses US (NASD) 30/360 basis.
EXAMPLEInterest Calculation
Year fraction for annual interest accrual
DAYS
Date FunctionsExplanation
Returns the number of days between two dates.
EXAMPLEDuration
Days between dates
TODAY
Date FunctionsExplanation
Returns the current date (system time).
EXAMPLECurrent Date
Get today's date
NOW
Date FunctionsExplanation
Returns the current date and time.
EXAMPLETimestamp
Get current timestamp
Financial Functions
PMT
Financial FunctionsExplanation
Calculates the periodic payment for a loan based on constant payments and a constant interest rate.
EXAMPLEMortgage Payment
Monthly payment for $400k loan at 8% for 30 years
NPER
Financial FunctionsExplanation
Calculates the number of periods for an investment based on periodic, constant payments and a constant interest rate.
EXAMPLEPayoff Time
Months to pay off loan with extra payments
IPMT
Financial FunctionsExplanation
Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
EXAMPLEInterest Portion
Interest paid in the first month
PPMT
Financial FunctionsExplanation
Returns the payment on the principal for a given period.
EXAMPLEPrincipal Portion
Principal paid in the first month
CUMIPMT
Financial FunctionsExplanation
Returns the cumulative interest paid between two periods.
EXAMPLEFirst Year Interest
Total interest paid in first 12 months
CUMPRINC
Financial FunctionsExplanation
Returns the cumulative principal paid between two periods.
EXAMPLEFirst Year Principal
Total principal paid in first 12 months
FV
Financial FunctionsExplanation
Calculates the future value of an investment based on a constant interest rate.
EXAMPLESavings Growth
Future value of monthly savings
PV
Financial FunctionsExplanation
Calculates the present value of a loan or an investment, based on a constant interest rate.
EXAMPLELoan Amount
How much can I borrow?
Logical
IF
LogicalExplanation
Evaluates a condition and returns one of two values based on the result. Uses numeric comparison where 0 is false and any other value is true.
EXAMPLERevenue Milestone Bonus
Apply bonus if revenue target is exceeded
EXAMPLETiered Pricing
Apply different pricing based on volume
EXAMPLECredit Risk Assessment
Determine credit limit based on payment history
AND
LogicalExplanation
Returns 1 (true) if all conditions are true, otherwise returns 0 (false).
EXAMPLEInvestment Approval Criteria
Check if all investment criteria are met
OR
LogicalExplanation
Returns 1 (true) if any condition is true, otherwise returns 0 (false).
EXAMPLEAccount Review Flag
Flag accounts needing review based on multiple risk factors
NOT
LogicalExplanation
Returns the logical opposite: 1 (true) if condition is false, 0 (false) if condition is true.
EXAMPLENon-Performing Assets
Identify assets not meeting performance threshold
Comparison Operators
LogicalExplanation
Comparison operators that return 1 (true) or 0 (false). Used in IF conditions and logical expressions.
EXAMPLEBasic Comparisons
All comparison operators
EXAMPLEIn IF Conditions
Use comparison operators to build conditional logic
Lookup & Reference
LOOKUP
Lookup & ReferenceExplanation
Searches for a value. Can work in two modes: 1) XLOOKUP style searching arrays, or 2) Object property lookup where it finds a key in a dictionary object.
EXAMPLEFind Rate (Array Mode)
Look up tax rate by region
EXAMPLEObject Property
Get value from a specific property key in an object
IFERROR
Lookup & ReferenceExplanation
Returns value_if_error if the expression evaluates to an error; otherwise, returns the value of the expression.
EXAMPLESafe Division
Handle division by zero
Math Functions
POWER
Math FunctionsExplanation
Returns the result of a number raised to a power.
EXAMPLECompound Interest Factor
Calculate growth factor
ROUND
Math FunctionsExplanation
Rounds a number to a specified number of digits using MidpointRounding.AwayFromZero (standard financial rounding).
EXAMPLERound Currency
Round price to 2 decimal places
ROUNDUP
Math FunctionsExplanation
Rounds a number away from zero to the specified number of digits. (e.g. -3.14 to 1 digit becomes -3.2).
EXAMPLECeiling for Pricing
Always round up to next cent
ABS
Math FunctionsExplanation
Returns the absolute value of a number.
EXAMPLEVariance Magnitude
Get absolute variance regardless of direction
Arithmetic Operators
Math FunctionsExplanation
Standard arithmetic operators for calculations. IMPORTANT: Use ^ for exponentiation, NOT **.
EXAMPLEBasic Arithmetic
Addition, subtraction, multiplication, division
EXAMPLEPower / Exponentiation
CRITICAL: Use ^ for power operations, NOT **
EXAMPLEMortgage Payment Calculation
Use ^ for loan amortization formulas
Patterns & Practices
Excel to CostVela
Patterns & PracticesExplanation
Guide for translating common Excel patterns to CostVela DSL. Move from cell-based logic to named, structural logic.
EXAMPLEVLOOKUP / XLOOKUP
Replace lookups with conditionals or logic. (For simple tiered logic)
EXAMPLESUMIF / SUMIFS
Filter data using MAP and logic before summing.
EXAMPLEAbsolute References ($A$1)
Use Constants or single variables.
Structuring Models
Patterns & PracticesExplanation
Tips for organizing your model for readability and maintainability.
EXAMPLERecommended Layout
Group Inputs, Constants, and Logic clearly.
EXAMPLENaming Conventions
Use clear, descriptive snake_case names.
DSL Best Practices
Patterns & PracticesExplanation
Essential rules to follow when writing CostVela DSL models to avoid common errors.
EXAMPLENo Unused Variables
Every variable you define must be used somewhere in the model.
EXAMPLEUse ^ for Power, NOT **
The exponentiation operator is ^ (caret), not ** (double asterisk)
EXAMPLEDefine Before Use
Variables must be defined before they are referenced
Common Mistakes
Patterns & PracticesExplanation
A list of common pitfalls and syntax errors to avoid.
EXAMPLEUsing != instead of <>
The not-equal operator is <> (SQL style). The C/JS style != is NOT supported.
EXAMPLEConst with Arrays
Const() only supports scalar values (numbers/strings). For arrays, use Input() and define the array in the inputs JSON.
Text Functions
CONCAT
Text FunctionsExplanation
Concatenates a list of text strings or numbers.
EXAMPLEJoin Strings
Join two words
EXAMPLEJoin Number
Create a label