Day(Calendar: IDimInstance; El: Integer): Integer;
Day(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 Day method returns the index of the element that correlates to the start of a calendar period containing the specified element.
For correct calculation the calendar dictionary must contain the Days level.
For example, if the calendar dictionary contains Years, Quarters, Days levels and the calculation is executed for:
Element of the quarterly frequency, the Day method returns the element corresponding to the start of the quarter.
Element of the annual frequency, the Day method returns the element corresponding to the start of the year.
The example is the function that is used to calculate relations in a standard cube.
Add links to the Cubes, Dimensions system assemblies.
Function GetLag(DimInst: IDimInstance; El: Integer): Integer;
Var
Result: Integer;
Begin
// Calculate
If CalendarDimension.Level(DimInst, El) = DimCalendarLevel.Day Then
Result := CalendarDimension.Day(DimInst, CalendarDimension.Shift(DimInst, El, 365));
Else
Result := -1;
End If;
// Return the result
Return Result;
End Function GetLag;
Public Function Lag(T: Variant): Variant;
Var
Cube: ICubeInstance;
CubeDest: ICubeInstanceDestination;
DimInsts: ICubeInstanceDimensions;
DimInst: IDimInstance;
Res: Array Of Integer;
I: Integer;
Cnt: Integer;
Begin
// Get current cube
Cube := CubeClass.CurrentCube;
CubeDest := Cube.Destinations.DefaultDestination;
// Find calendar dimension
DimInsts := CubeDest.Dimensions;
Cnt := DimInsts.Count;
For I := 0 To Cnt - 1 Do
If DimInsts.Item(I).Dimension.IsCalendar Then
DimInst := DimInsts.Item(I);
End If;
End For;
// Determine whether it is possible to have an array as input parameter T
If T.VarType = ForeVariantType.Matrix Then
Res := T As Array Of Integer;
Cnt := Res.Length;
For I := 0 To Cnt - 1 Do
Res[I] := GetLag(DimInst, Res[I]);
End For;
// Return result
Return Res;
Else
//Return integer value
Return GetLag(DimInst, T);
End If;
End Function Lag;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
…
Public Shared Function Day(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.dclMonth Then
Result := calendDim.Day(DimInst, el) As integer;
Else
Result := -1;
End If;
// Return result
Return Result;
End Function Day;
The result of using the relation in the formula of the calculated fact: the value for the element of the monthly frequency will be taken from the last day of the month.
See also: