Circular dependencies arise when a model needs to create cyclical expressions, such as stock levels that oscillate predictably over a month or week. This article provides context for error messages arising from cyclical expressions in Pigment.
About circular dependencies
The formula below is an example of a circular dependency within a single Block:
'Metric A' = 'Metric A'ASELECT: Month - 1] + 1
It attempts to increase Metric A by one, month-on-month, but would result in an error message, as Metric A cannot reference itself in the formula.
The Pigment modeling engine computes formulas in sequence. Each time a formula in a Block is created or edited, all of the Blocks using the original Block in their formulas are automatically recalculated. Creating a circular dependency could lead to an infinite loop of calculations.
For that reason, each time a formula is created or edited, the Pigment engine checks if the new formula would create a circular dependency, flagging errors such as the below when circular referencing cannot be resolved:



Debug circular dependency errors
When an error occurs, Pigment lists the Metrics involved in the circular dependency, helping you trace the issue. To debug, first check that your formulas do not have a circular dependency at cell-level, for example:
'Metric A' = 'Metric A' + 1
Pigment does not support these types of circular reference, and it will always fail because the Metric is asking for its own value.
If you need a Metric to “build on itself” over time (for example, month-over-month growth), use the function for iterative calculations for single Blocks instead of direct self-reference.
Circular dependencies can also occur between Metrics. Pigment allows these only through the iterative calculation feature (see Iterative Calculations across multiple Blocks using PREVIOUSOF). In this setup, formulas can safely reference each other as long as:
-
They are all included in the configuration, and
-
They do not make cell-level self-references.
If you see an error in this case, check that all listed Metrics are properly included in the configuration.
Functions for models requiring circular reference
If a model requires a circular reference, Pigment offers two functions that unblock this capability. Find guidance in the articles provided.
| Description | Solution | Article |
---|---|---|---|
Single-Block | The Metrics containing circular-referencing formulas exist within one Block |
| |
Multiple-Block | The Metrics containing circular-referencing formulas exist within different Blocks |
| Iterative Calculations across multiple Blocks using PREVIOUSOF |