Year(Calendar: IDimInstance; El: Integer): Integer;
Year(Calendar: Prognoz.Platform.Interop.Dimensions.IDimInstance; El: uinteger): uinteger;
Calendar. Data of the calendar dictionary, by which calculation is executed.
El. Index of the element, relative to which calculation is executed.
The Year method returns index of the element corresponding to the year, which includes the specified element.
For correct calculation the calendar dictionary must contain the Years level. If the level is missing, the method returns -1.
For example, if the calendar dictionary contains Years, Months, Days levels and the calculation is executed for:
Element of the monthly frequency, the Year method returns the element corresponding to the year, which includes the month.
Element of the daily frequency, the Year method returns the element corresponding to the year, which includes the day.
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.
Function Year(T: Variant): Integer;
Var
Cube: ICubeInstance;
CubeDest: ICubeInstanceDestination;
DimInsts: ICubeInstanceDimensions;
DimInst: IDimInstance;
i: Integer;
Result: Integer;
Begin
// Get the current cube
Cube := CubeClass.CurrentCube;
CubeDest := Cube.Destinations.DefaultDestination;
// Get calendar dimension
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;
// Execute calculation
If CalendarDimension.Level(DimInst, t) = DimCalendarLevel.Quarter Then
Result := CalendarDimension.Year(DimInst, t);
Else
Result := -1;
End If;
// Return result
Return Result;
End Function Year;
The result of using the relation in the formula of the calculated fact: the value for the elements of the quarterly frequency will be taken from the value of the corresponding elements of the annual 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 Year(T: object): Integer;
Var
cClass: CubeClassClass;
Cube: ICubeInstance;
CubeDest: ICubeInstanceDestination;
DimInsts: ICubeInstanceDimensions;
DimInst: IDimInstance;
i: Integer;
calendDim: CalendarDimension;
el: uinteger;
Result: Integer;
Begin
// Get the current cube
cClass := New CubeClassClass.Create();
Cube := cClass.CurrentCube[Null];
CubeDest := Cube.Destinations.DefaultDestination;
// Get calendar dimension
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;
// Execute calculation
calendDim := New CalendarDimension.Create();
el := uinteger.Parse(t.ToString());
If calendDim.Level(DimInst, el) = DimCalendarLevel.dclQuarter Then
Result := calendDim.Year(DimInst, el) As integer;
Else
Result := -1;
End If;
// Return result
Return Result;
End Function Year;
The result of using the relation in the formula of the calculated fact: the value for the elements of the quarterly frequency will be taken from the value of the corresponding elements of the annual frequency.
See also: