CumulativeMethod: MsCumulativeMethodType;
The CumulativeMethod property determines a cumulative method.
The property is set to MsCumulativeMethodType.Average by default.
Executing the example requires that the repository contains a modeling container with the MS identifier. This container contains a cumulative model with the MODEL_CUMULATIVE identifier.
Add links to the Cubes, Dimensions, Ms, and Metabase system assemblies.
Sub UserProc;
Var
mb: IMetabase;
ModelCont: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
TransformVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
Formula: IMsFormula;
CumTr: IMsCumulativeTransform;
trInfo: IMsFormulaTermInfo;
DataSC: IVariableStub;
Calcul: IMsModelCalculation;
SelSetFactory: IDimSelectionSetFactory;
SelSet: IDimSelectionSet;
Sel: IDimSelection;
i: Integer;
ResultVals: Array Of Double;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modeling container
ModelCont := mb.ItemById("MS");
// Get cumulative model
Model := mb.ItemByIdNamespace("MODEL_CUMULATIVE", ModelCont.Key).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
Formula := Transform.FormulaItem(0);
CumTr := Formula.Method As IMsCumulativeTransform;
// Replace input variable
Transform.Inputs.Clear;
DataSC := (ModelCont.Bind As IMsModelSpace).DefaultObject As IVariableStub;
TransformVar := Transform.Inputs.Add(DataSC);
SelSetFactory := New DimSelectionSetFactory.Create;
SelSet := SelSetFactory.CreateDimSelectionSet;
For i := 0 To DataSC.DimensionCount - 1 Do
Sel := SelSet.Add((DataSC.Dimension(i) As IMetabaseObject).Open(Null) As IDimInstance);
Sel.SelectElement(2, False);
End For;
Slice := TransformVar.Slices.Add(SelSet);
trInfo := Transform.CreateTermInfo;
trInfo.Slice := Slice;
CumTr.Input := trInfo;
// Determine cumulative method
CumTr.CumulativeMethod := MsCumulativeMethodType.Median;
// Create calculation parameters
calcul := Model.CreateCalculation;
calcul.Period.IdentificationStartDate := Transform.Period.IdentificationStartDate;
calcul.Period.IdentificationEndDate := Transform.Period.IdentificationEndDate;
calcul.Period.ForecastStartDate := Transform.Period.ForecastStartDate;
calcul.Period.ForecastEndDate := Transform.Period.ForecastEndDate;
// Get and display values of output variable
ResultVals := CumTr.Result.Serie(Calcul As IMsMethodCalculation);
For i := 0 To ResultVals.Length - 1 Do
Debug.WriteLine(ResultVals[i]);
End For;
// Save model
(Model As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the input variable and the cumulative calculation method will be changed for the model. The console window displays values of output variable.
See also: