AgregationMethod: MsAgregationMethodType;
AgregationMethod: Prognoz.Platform.Interop.Ms.MsAgregationMethodType;
The AgregationMethod property selects aggregation method.
Use the IMsCrossDimensionAggregationTransform.Expression property to get aggregation expression.
Executing the example requires a form that contains the Button component with the button1 identifier, the LanerBoxNet component with the lanerBoxNet1 identifier and the UiErAnalyzer component with the uiErAnalyzer1 identifier. Specify UiErAnalyzer1 as a data source for the LanerBox1 component. The time series database workbook must be loaded to the UiErAnalyzer1 component. The example is a handler of the OnClick event for the Button1 component.
Add links to the Metabase, Ms, Cubes, Rds, Metabase, Dimensions system assemblies.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
mb: IMetabase;
Laner: ILaner;
CalcSerie: ILanerCalculateSerie;
Transform: IMsFormulaTransform;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
Method: IMsMethod;
Aggr: IMsCrossDimensionAggregationTransform;
TransformVar: IMsFormulaTransformVariable;
Options: IMsCrossDimensionAggregationOptions;
FilterList: IMsAggregationFilterList;
Filter: IMsAggregationFilter;
Rubr: IRubricator;
Attributes: IMetaAttributes;
DictDescr: IMetabaseObjectDescriptor;
FilterDimension: IMetabaseObject;
DimInst: IDimInstance;
Selection: IDimSelection;
i: Integer;
Begin
mb := MetabaseClass.Active;
Laner := UiErAnalyzer1.ErAnalyzer.Laner;
Laner.BeginUpdate;
CalcSerie := Laner.Series.AddCalculateSerie("Aggregation");
Transform := CalcSerie.Transform.Transform As IMsFormulaTransform;
Selector := Transform.CreateSelector;
TransformVar := Transform.Outputs.Item(0);
Selector.Slice := TransformVar.Slices.Add(Null);
Formula := Transform.Transform(Selector);
Formula.Kind := MsFormulaKind.CrossDimensionAggregation;
Method := Formula.Method;
// Set up aggregation
Aggr := Method As IMsCrossDimensionAggregationTransform;
// Set aggregation method
Aggr.AgregationMethod := MsAgregationMethodType.Sum;
// Determine additional aggregation parameters
Options := Aggr.Options;
Options.Threshold := 0;
Options.Level := False;
Options.Rebase := False;
// Set up aggregation filter
FilterList := Aggr.Filter;
FilterList.Clear;
Rubr := Laner.RubricatorInstance.Rubricator;
Attributes := Rubr.Facts.Attributes;
DictDescr := Attributes.FindById("COUNTRY").ValuesObject;
Filter := FilterList.Add(DictDescr.Bind As IDimensionModel);
FilterDimension := Filter.FilterDimension As IMetabaseObject;
DimInst := FilterDimension.Open(Null) As IDimInstance;
Selection := DimInst.CreateSelection;
For i := 0 To 3 Do
Selection.SelectElement(i, False);
End For;
Filter.AggregationSelection := Selection;
// Set dimension, by which aggregation is executed
DictDescr := Attributes.FindById("INDICATOR").ValuesObject;
Aggr.AggregationDimenson := DictDescr.Bind As IDimensionModel;
// Set aggregation expression
Aggr.Expression.AsString := "{BCA[t]}";
LanerBox1.ExecuteOperation(LanerBoxOperation.Refresh);
Laner.EndUpdate;
End Sub Button1OnClick;
After executing the example the Aggregation series, calculated by the aggregation method will be added to the LanerBox component. Aggregation is calculated as a sum of the BCA factor values for the first four countries of the dictionary, to which the COUNTRY attribute refers. For example:
Executing the example requires a form that contains the Button component with the button1 identifier, the LanerBoxNet component with the lanerBoxNet1 identifier and the UiErAnalyzerNet component with the uiErAnalyzerNet1 identifier. Specify uiErAnalyzerNet1 as a data source for the lanerBoxNet1 component. The time series database workbook must be loaded to the uiErAnalyzerNet1 component. The example handles the Click event for the button1 component.
Add links to the Ms, Cubes, Rds, Dimensions, Laner, Express system assemblies.
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Rds;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Laner;
Imports Prognoz.Platform.Interop.Express;
…
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
mb: IMetabase;
Laner: ILaner;
CalcSerie: ILanerCalculateSerie;
Transform: IMsFormulaTransform;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
Method: IMsMethod;
Aggr: IMsCrossDimensionAggregationTransform;
TransformVar: IMsFormulaTransformVariable;
Options: IMsCrossDimensionAggregationOptions;
FilterList: IMsAggregationFilterList;
Filter: IMsAggregationFilter;
Rubr: IRubricator;
Attributes: IMetaAttributes;
DictDescr: IMetabaseObjectDescriptor;
FilterDimension: IMetabaseObject;
DimInst: IDimInstance;
Selection: IDimSelection;
i: uinteger;
Begin
mb := Self.Metabase;
Laner := uiErAnalyzerNet1.ErAnalyzer.ErAnalyzer.Laner;
Laner.BeginUpdate();
CalcSerie := Laner.Series.AddCalculateSerie("Aggregation", DimCalendarLevel.dclYear, -1);
Transform := CalcSerie.Transform.Transform As IMsFormulaTransform;
Selector := Transform.CreateSelector();
TransformVar := Transform.Outputs.Item[0];
Selector.Slice := TransformVar.Slices.Add(Null);
Formula := Transform.Transform[Selector];
Formula.Kind := MsFormulaKind.mfkCrossDimensionAggregation;
Method := Formula.Method;
// Set up aggregation
Aggr := Method As IMsCrossDimensionAggregationTransform;
// Set aggregation method
Aggr.AgregationMethod := MsAgregationMethodType.mammtSum;
// Determine additional aggregation parameters
Options := Aggr.Options;
Options.Threshold := 0;
Options.Level := False;
Options.Rebase := False;
// Set up aggregation filter
FilterList := Aggr.Filter;
FilterList.Clear();
Rubr := Laner.RubricatorInstance.Rubricator;
Attributes := Rubr.Facts.Attributes;
DictDescr := Attributes.FindById("COUNTRY").ValuesObject;
Filter := FilterList.Add(DictDescr.Bind() As IDimensionModel);
FilterDimension := Filter.FilterDimension As IMetabaseObject;
DimInst := FilterDimension.Open(Null) As IDimInstance;
Selection := DimInst.CreateSelection();
For i := 0 To 3 Do
Selection.SelectElement(i, False);
End For;
Filter.AggregationSelection := Selection;
// Set the dimension, by which aggregation is executed
DictDescr := Attributes.FindById("INDICATOR").ValuesObject;
Aggr.AggregationDimenson := DictDescr.Bind() As IDimensionModel;
// Set aggregation expression
Aggr.Expression.AsString := "{BCA[t]}";
lanerBoxNet1.CtrlBox.ExecuteOperation(LanerBoxOperation.lboRefresh, Null);
Laner.EndUpdate();
End Sub;
The result of the Fore.NET example execution matches with that in the Fore example.
See also: