Aggregator(FactKey: Variant; Destination: IStandardCubeDestination): IMatrixAggregatorModel;
FactKey. Value of the primary key of the fact dimension element, for which one should set up aggregation.
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 that the repository contains a standard cube with the STD_CUBE identifier. The cube contains a calendar dimension with the CALENDAR identifier. There are at least two levels in this dimension.
Add links to the Cubes, Dimensions, Matrix, and Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
StdCube: 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;
StdCube := MB.ItemById("STD_CUBE").Edit As IStandardCube;
Dest := StdCube.Destinations.Item(0);
// Create a new aggregator
Man := New MatrixAggregatorManager.Create As IMatrixAggregatorManager;
// Chronological aggregation mechanism
ChronAggr := Man.CreateAggregator("ChronologicalMatrixAggregator") As IChronologicalMatrixAggregator;
// For dimension - calendar
Dim := Dest.Dimensions.FindById("D_CALENDAR");
DimModel := Dim.Dimension;
ChronAggr.Dimension := DimModel;
// Source level
LevAggr := ChronAggr.LevelAggregation(DimModel.Levels.Item(0));
// Method - uniform disaggregation
LevAggr.Operation := ChronologicalAggregatorOperation.UniformDisaggregation;
// Consumer level
LevAggr.SourceLevel := DimModel.Levels.Item(1);
// Get fact dimension elements to set aggregation for them
FactDim := Dest.FactDimension;
// If the fact dimension is local, get the list of elements using ICustomDimension.Elements,
// otherwise open the dictionary used as a fact dimension
If StdCube.ExternalFactDimension = False Then
// Fact dimension elements
CustomElements := (FactDim.Dimension As ICustomDimension).Elements;
// Set the selected aggregation mechanism
For i := 0 To CustomElements.RowCount - 1 Do
// By default, element key is stored in attribute with the 0 index
// Set aggregation for 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 the selected aggregation mechanism
For i := 0 To DimElements.Count - 1 Do
// Primary key in the dictionary is the attribute with the Identifier purpose
// Set aggregation for element by value of this attribute
Dim.Aggregator(DimElements.Id(i), Dest) := ChronAggr;
End For;
End If;
(StdCube As IMetabaseObject).Save;
End Sub UserProc;
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 fact dimension.
See also: