Aggregator(FactKey: Variant; Destination: IStandardCubeDestination): IMatrixAggregatorModel;
FactKey. Key of the facts dimension element, for which aggregation must be set up.
Destination. Cube display version, for which aggregation must be set up.
The Aggregator property determines settings of aggregation dimension by the specified cube fact.
Executing the example requires a standard cube with the Stand_Cube identifier. The cube contains a calendar dimension with the CALENDAR identifier. There are at least two levels in this dimension.
Sub Main;
Var
MB: IMetabase;
MObj: IMetabaseObject;
StandCub: IStandardCube;
Man: IMatrixAggregatorManager;
Dest: IStandardCubeDestination;
Dim: IStandardCubeDimension;
DimModel: IDimensionModel;
ChronAggr: IChronologicalMatrixAggregator;
LevAggr: IChronologicalMatrixLevelAggregator;
FactDim: IStandardCubeDimension;
CustomElements: ICustomDimElements;
DimInst: IDimInstance;
DimElements: IDimElements;
i: Integer;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("Stand_Cube").Edit;
StandCub := MObj As IStandardCube;
//Create new aggregator
Man := New MatrixAggregatorManager.Create As IMatrixAggregatorManager;
//Chronological aggregation mechanism
ChronAggr := Man.CreateAggregator("ChronologicalMatrixAggregator") As IChronologicalMatrixAggregator;
//For dimension - calendar
Dim := StandCub.Dimensions.FindById("CALENDAR");
DimModel := Dim.Dimension;
ChronAggr.Dimension := DimModel;
//Source level
LevAggr := ChronAggr.LevelAggregation(DimModel.Levels.Item(0));
//Method - uniform disaggregation
LevAggr.Operation := ChronologicalAggregatorOperation.UniformDisaggregation;
//Destination level
LevAggr.SourceLevel := DimModel.Levels.Item(1);
//Receive facts dimension elements to set aggregation by them
Dest := StandCub.Destinations.Item(0);
FactDim := StandCub.FactDimension;
//If facts dimension is local, the list of elements is received using ICustomDimension.Elements,
//otherwise close dictionary that is used as the facts dimension
If StandCub.ExternalFactDimension = False Then
//Facts dimension elements
CustomElements := (FactDim.Dimension As ICustomDimension).Elements;
//Set selected aggregation mechanism
For i := 0 To CustomElements.RowCount - 1 Do
//By default key of elements is stored in attribute with index 0
//Set aggregation for the element by its key
Dim.Aggregator(CustomElements.AttributeValue(i, 0), Dest) := ChronAggr;
End For;
Else
//Dictionary data
DimInst := (FactDim.Dimension As IMetabaseObject).Open(Null) As IDimInstance;
//Dictionary elements
DimElements := DimInst.Elements;
//Set selected aggregation mechanism
For i := 0 To DimElements.Count - 1 Do
//First key in the dictionary is the attribute with the Identifier purpose
//Set aggregation for the element by the value of its attribute
Dim.Aggregator(DimElements.Id(i), Dest) := ChronAggr;
End For;
End If;
MObj.Save;
End Sub Main;
After executing the example the data aggregation is set up for the calendar dimension of a cube. Uniform data disaggregation is executed from the first level existing in the calendar dimension to the second level of the calendar. This aggregation method is set for all elements of facts dimension.
See also: