Description
Returns the value of the previous cell of the current Metric in the iteration Dimension.
This function allows you to create single Metric iterative calculations.
For more information on how to create iterative calculations, see Iterative Calculations Within a Block Using PREVIOUS.
Syntax
PREVIOUS(Iteration Dimension i, Offset])
Arguments
Argument | Type | Dimensions | Descriptions |
---|---|---|---|
Iteration Dimension (required) | Number | Any Dimension included in the Metric structure | Dimension of the current Metric to which you want to apply an offset. |
Offset (optional) | Integer or Metric | No Dimension or same as the Metric | Number of cells to offset. If you leave this argument blank, a default value of If you offset by calling a Metric, blank cells in the Metric result in PREVIOUS not applying. Note that Metrics for offsetting can have the same Dimensions as the current Metric or fewer. |
Returns
Type | Dimensions |
---|---|
Same as the current Metric | Same as the current Metric |
Examples
Formula | Description |
---|---|
PREVIOUS(Month) | Returns the value of the previous month value of the current Metric. |
PREVIOUS(Month,2) | Returns the value of the current Metric cell, from two months previous. |
Limitations
To avoid cell-level circular dependencies and optimize computation time, Pigment restricts the use of the PREVIOUS function in the following ways:
-
Iterating Dimension used with PREVIOUS has a maximum of 10,000 Items
You can usePREVIOUS()
with any Dimension, but it can’t have more than 10,000 Items.
- Combining Multiple Dimensions to Offset
It is not possible to combine multiple PREVIOUS() functions using different Dimensions to offset in a given formula. For example, you can’t use this formula:PREVIOUS(Month) + PREVIOUS(Product)
You can achieve similar calculation in logic with a construct as follows:PREVIOUS(Month)sSELECT: Product -1]
- Advanced Function Compatibility
The PREVIOUS function is incompatible with some of the other functions available in Pigment. These include:- IRR / XIRR/ NPV
- DOUBLE_EXPONENTIAL_SMOOTHING / SIMPLE_EXPONENTIAL_SMOOTHING
- FORECAST_LINEAR, FORECAST_ETS, SEASONAL_LINEAR_REGRESSION
- DAYSINPERIOD, PRORATA, DAYSINPERIODWITHHOLIDAYS, PRORATAWITHHOLIDAYS
- Offset
The offset parameter needs to be positive (negative offsets are ignored and considered blank). For example,PREVIOUS(Month, -1)
would be ignored. Integer offsets tend to result in faster computation speeds than offsets through a Metric.
- Performance
Sparse datasets allow for much faster computation. The PREVIOUS function can densify your model, as it adds values in the Metric where it is being used, and thus reduce performance.
For more context around limitations of usingPREVIOUS()
, see Iterative Calculations Within a Block Using PREVIOUS.
See Also
Excel: no equivalent
Related articles: