ShiftLevel(Calendar: IDimInstance;
El: Integer;
Lag: Integer;
Level: DimCalendarLevel): Integer;
ShiftLevel(Calendar: Prognoz.Platform.Interop.Dimensions.IDimInstance;
El: uinteger;
Lag: integer;
Level: Prognoz.Platform.Interop.Dimensions.DimCalendarLevel): uinteger;
Calendar. Data of the calendar dictionary, by which calculation is executed.
El. Index of the element, relative to which calculation is executed.
Lag. Element shifting.
Level. The level, on which shifting is executed.
The ShiftLevel method returns index of the element obtained by shifting relative to the specified element on the specified level.
The method calculates shift within one specified calendar level. If the element obtained as a result of shifting is missing in the calendar, the method returns -1. If the specified calendar level is missing, the method throws an exception.
To shift forward within time period, specify negative value of the Lag parameter, to shift backward, specify positive value.
The example is the function that is used to calculate the relation in a standard cube.
To execute the example, add links to the Cubes and Dimensions system assemblies.
Public Function ShiftLevel(T: Variant; Lag: Integer): Integer;
Var
Cube: ICubeInstance;
CubeDest: ICubeInstanceDestination;
DimInsts: ICubeInstanceDimensions;
DimInst: IDimInstance;
i: Integer;
Result: Integer;
Begin
Cube := CubeClass.CurrentCube;
CubeDest := Cube.Destinations.DefaultDestination;
DimInsts := CubeDest.Dimensions;
For i := 0 To DimInsts.Count - 1 Do
If (DimInsts.Item(i).Dimension Is ICalendarDimension) Then
DimInst := DimInsts.Item(i);
End If;
End For;
Result := CalendarDimension.ShiftLevel(DimInst, t, Lag, DimCalendarLevel.Year);
Return Result;
End Function ShiftLevel;
The result of using a relation in the formula of the calculated fact: the value for all elements of the annual frequency will be shifted. Direction and size of shifting are specified by the user via the Lag input parameter.
The example is the function that is used to calculate the relation in a standard cube.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
…
Public Shared Function ShiftLevel(T: object; Lag: Integer): integer;
Var
cClass: CubeClassClass;
Cube: ICubeInstance;
CubeDest: ICubeInstanceDestination;
DimInsts: ICubeInstanceDimensions;
DimInst: IDimInstance;
i: integer;
calendDim: CalendarDimension;
el: uinteger;
Result: integer;
Begin
cClass := New CubeClassClass.Create();
Cube := cClass.CurrentCube[Null];
CubeDest := Cube.Destinations.DefaultDestination;
DimInsts := CubeDest.Dimensions;
For i := 0 To DimInsts.Count - 1 Do
If (DimInsts.Item[i].Dimension Is ICalendarDimension) Then
DimInst := DimInsts.Item[i];
End If;
End For;
calendDim := New CalendarDimension.Create();
el := uinteger.Parse(t.ToString());
Result := calendDim.ShiftLevel(DimInst, el, Lag, DimCalendarLevel.dclYear) As integer;
Return Result;
End Function ShiftLevel;
The result of using a relation in the formula of the calculated fact: the value for all elements of the annual frequency will be shifted. Direction and size of shifting are specified by the user via the Lag input parameter.
See also: