TimeBackwardLag: Integer;
The TimeBackwardLag property determines the value that is an increase in the selection back (lag back) for the specified calendar level.
Selection increase is used to extract additional values, which may be required to calculate formulas. The actual calculation will be made according to the selection specified in the ICubeInstanceDestination.Execute method.
Executing the example requires that the repository contains a standard cube with the STD_CUBE identifier. The cube fact dimension has at least two elements: the first element is linked to the data source field, the second element is not linked. Cube structure contains a calendar dimension.
Add links to the Cubes, Db, Dimensions and Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
StdCube: IStandardCube;
StdCubeDest: IStandardCubeDestination;
CalcBind: IStandardCubeCalculatedFactBinding;
Relation: IStandardCubeRelation;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("STD_CUBE").Edit;
StdCube := MObj As IStandardCube;
StdCubeDest := StdCube.Destinations.Item(0);
//Create a relation
Relation := StdCubeDest.Relations.Add;
Relation.Id := "PREVIOUS_VALUE";
Relation.Name := "PREVIOUS_VALUE";
//Relation formula for calendar dimension
Relation.Relation(StdCubeDest.Dimensions.Calendar).AsString := "T.PREV";
//Binding of the second (calculated) fact
CalcBind := StdCubeDest.CalcBindings.Binding(2) As IStandardCubeCalculatedFactBinding;
CalcBind.Formula.AsString := "@[1]-PREVIOUS_VALUE[@[1]]";
//Set lag for calculated factor
CalcBind.TimeLagLevel := DimCalendarLevel.Year;
CalcBind.TimeBackwardLag := 2;
MObj.Save;
End Sub UserProc;
On executing the example a relation is created in the cube, and a calculated fact is set up. The relation will extract the previous value towards the current calculation point by calendar dimension. The calculation fact, using the relation, will calculate the difference between the current and the previous value. The lag will be also set for the calculated fact, according to which selection will increase on extracting values for calculation.
See also: