MatrixAggregator(
Stub: IVariableStub;
DimInstance: IDimInstance): IBasicMatrixAggregator;
Stub. Structure of the variable, within which the aggregation is performed.
DimInstance. Data that must be aggregated.
The MatrixAggregator property returns an object that contains properties and methods required for data aggregation.
Public Class My_Method: Object, IMsUserTransformImplementation
Sub Execute(Calculation: IMsMethodCalculation; Coo: IMsFormulaTransformCoord;
Explained: IMsFormulaTerm; Explanatories: IMsFormulaTermList);
Var
ExpVarStub: IVariableStub;
Matr: IMatrix;
CalendarInst: IDimInstance;
BasicAggr: IBasicMatrixAggregator;
LevAggr: IBasicMatrixLevelAggregator;
Lvls: IDimLevelsInstance;
Cub: ICubeInstance;
Begin
ExpVarStub := Explained.Slice.Variable.VariableStub;
Matr := Calculation.Variable(ExpVarStub);
CalendarInst := (ExpVarStub.Calendar As IMetabaseObject).Open(Null) As IDimInstance;
BasicAggr := Calculation.MatrixAggregator(ExpVarStub, CalendarInst);
//For level by default
Lvls := CalendarInst.Levels;
LevAggr := BasicAggr.LevelAggregation(Lvls.Item(0).Level);
LevAggr.Operation := BasicAggregatorOperation.ArithmeticalMean;
LevAggr.Include(Lvls.Item(1).Level) := True;
//Receive the matrix of aggregated data
Matr := BasicAggr.Execute(0, Matr);
//Save the aggregated data to cube of variable
Cub := ((ExpVarStub As IMsVariable).Cube As IMetabaseObject).Open(Null) As ICubeInstance;
Cub.Destinations.DefaultDestination.CreateStorage.SaveMatrix(Matr, Matr.ValueFlag);
End Sub Execute;
Sub Set_params(ParamValue: IMsUserMethodParams);
Begin
//Receive the value of parameters
End Sub Set_params;
End Class My_Method;
This example is a macro that contains a user method of model calculation. The modelling model variable, that uses the user method at calculation, must have two calculation steps in its structure. At model calculation the data is aggregated in the output variable. Aggregation is made from lower to upper level using the method of arithmetical mean.
See also:
IMsMethodCalculation|IMsUserTransform|IMsUserTransform.Assembly|IMsUserTransform.ClassName