Skip to main content

Designing a Calculation Model

Learn how to connect variables through formulas, manage dimensionality, handle redimensioning, and build effective variable trees in Farseer.

Updated over 2 months ago

Overview

One of the most powerful features of Farseer is the ability to connect variables through formulas — effectively linking different snowflake topologies into new data structures. This article covers best practices for designing your calculation model.

Connecting Variables Through Formulas

When you write a formula that references another variable, you link their underlying data structures. For example:

Quantity [SKU, POS]

Revenue [SKU, POS]

Average Price [SKU, POS] = Revenue / Quantity

Since the average price per individual sales point might not be meaningful, you can remove the POS dimension to get the average across all sales points:

Average Price [SKU] = Revenue / Quantity

This flexibility is fundamental — by adjusting which dimensions are on the result variable, you control the level of aggregation.

The Variable Tree

When many variables are connected through formulas, they form a "variable tree" — a dependency chain that determines the order of execution. Understanding this tree is essential for debugging and optimization.

Example: Sales Model Variable Tree

Input variables:

  1. QUANTITY — number of units

  2. SKU PRICE — item price

  3. DISCOUNT % INPUT — discount per customer

  4. ADDITIONAL DISCOUNT AMOUNT — additional discount per customer

  5. COGS — Cost of Goods Sold

Calculation chain:

GROSS REVENUE = QUANTITY * SKU PRICE

DISCOUNT AMOUNT = DISCOUNT % INPUT * GROSS REVENUE

SEMI NET REVENUE = GROSS REVENUE - DISCOUNT AMOUNT

NET REVENUE = SEMI NET REVENUE - ADDITIONAL DISCOUNT AMOUNT

GROSS MARGIN = NET REVENUE - COGS

Each variable is evaluated in order based on its dependencies. You can view a variable's dependency chain in the variable editor under Used in Formula.

Working With Different Dimensionalities

When connecting variables, pay careful attention to their dimensions. The rules depend on the operation:

Same or Related Dimensions

Variables with the same dimensions can be freely added, subtracted, divided, and multiplied.

Different Dimensions — Mathematical Rules

  • Addition and Subtraction: Dimensions on both variables must be identical

  • Multiplication and Division: Dimensions can be different (but must still be at least related)

Redimensioning: Reducing Dimensionality

Sometimes you need to bring a variable with many dimensions into a context with fewer dimensions. You do this by creating an intermediate variable that "drops" the extra dimensions.

Example: Merging a sales model into a financial statement:

Revenue [SKU, POS]

Revenue to GL [GL Accounts] = Revenue — reduces dimensionality

GL Plan [GL Accounts] = Revenue to GL — uses the reduced variable

Redimensioning: Expanding Dimensionality

This is generally undesirable as it expands the table with repeating numbers. However, it's sometimes necessary — for example, when you have annual prices but need monthly granularity:

SKU Prices [SKU, POS, Years]

SKU Prices Monthly [SKU, POS, Years, Months] = SKU Prices — expansion

Revenue [SKU, POS, Years, Months] = SKU Prices Monthly * Quantities

Practical Example: Allocation Keys

One common use case for multiplying variables with different dimensions is allocation. For example, allocating operating expenses across products based on revenue:

OPEX [Years, Months, GL Accounts]

Revenue [Years, Months, POS, SKU]

Revenue Total [Years, Months, SKU]

Allocation Keys [Years, Months, SKU] = Revenue / Revenue Total

Allocated OPEX [Years, Months, SKU] = OPEX * Allocation Keys

Critical Warnings

  • No unrelated dimensions: If you connect variables that don't have even related dimensions, you can cause the evaluator to consume enormous memory and slow down the entire model

  • No loops: Ensure there are no circular references in the snowflake topology

  • Dimensions must be at least related for variables to be safely used together in formulas

Did this answer your question?