ToLevel(Calendar: IDimInstance;
El: Integer;
Level: DimCalendarLevel): Integer;
ToLevel(Calendar: Prognoz.Platform.Interop.Dimensions.IDimInstance;
El: uinteger;
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.
Level. Calendar level, on which calculation is executed.
The ToLevel method returns index of the element corresponding to the specified element on the specified level.
If the Level level is missing in the calendar dictionary, the method returns -1.
For example, if the calendar dictionary contains Years, Half-years, Quarters levels and the calculation is executed by the Half-year level for:
Element of the annual frequency, the ToLevel method returns the element corresponding to the first half-year.
Element of the quarterly frequency, the ToLevel method returns the element corresponding to the half-year, which includes the quarter.
Fore Example
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 ToLevel(T: Variant): 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.ToLevel(DimInst, t, DimCalendarLevel.Quarter);
Return Result;
End Function ToLevel;
The result of using the relation in the formula of the calculated fact: the value for all elements will be taken from the appropriate elements of the quarterly frequency.
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 ToLevel(T: object): 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.ToLevel(DimInst, el, DimCalendarLevel.dclQuarter) As integer;
Return Result;
End Function ToLevel;
The result of using the relation in the formula of the calculated fact: the value for all elements will be taken from the appropriate elements of the quarterly frequency.
See also: