IMsMatrixAggregationTransform.Aggregator

Fore Syntax

Aggregator(Dimension: IDimensionModel): IBasicMatrixAggregator;

Fore.NET Syntax

Aggregator[Dimension: Prognoz.Platform.Interop.Dimensions.IDimensionModel]: Prognoz.Platform.Interop.Matrix.IBasicMatrixAggregator;

Parameters

Dimension. Aggregated dimension.

Description

The Aggregator property returns aggregation parameters for the specified dimension.

Comments

To set aggregation filter, use the IMsMatrixAggregationTransform.Filter property.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a model with the MODEL_MATRIXAGGREGATION identifier. This model must calculate any of available methods. The model data source must also contain a dimension based on a table MDM dictionary with the MDM_DICT_GEOLOCATION identifier. This dictionary must contain three or more levels and a logical attribute with the ISCAPITAL identifier.

Add links to the Dimensions, Matrix, Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    pMsKey: Integer;
    pModel: IMsModel;
    pTransform: IMsFormulaTransform;
    pFormula: IMsFormula;
    pMethod: IMsMatrixAggregationTransform;
    pInfo: IMsFormulaTermInfo;
    pAggregator: IBasicMatrixAggregator;
    pLevelAgg: IBasicMatrixLevelAggregator;
    pDimModel: IDimensionModel;
    pDimInstance: IDimInstance;
    pDimLevels: IDimLevels;
    pAggDimSel, pFilterSelection: IDimSelection;
    pFilter: IMsAggregationFilter;
    pAdvancedFilterCondition: IMsDimIteratorAdvancedFilterCondition;
    i: Integer;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modelling container key
    pMsKey := mb.GetObjectKeyById("MS");
    // Get the model
    pModel := mb.ItemByIdNamespace("MODEL_MATRIXAGGREGATION", pMsKey).Edit As IMsModel;
    // Get model calculation parameters
    pTransform := pModel.Transform;
    // Get model calculation method
    pFormula := pTransform.FormulaItem(0);
    // Change model calculation method for matrix aggregation
    pFormula.Kind := MsFormulaKind.MatrixAggregation;
    // Get matrix aggregation calculation parameters
    pMethod := pFormula.Method As IMsMatrixAggregationTransform;
    // Create term
    pInfo := pTransform.CreateTermInfo;
    pInfo.Slice := pTransform.Outputs.Item(0).Slices.Item(0);
    // Get selection that is set by dimension that id based on the MDM_DICT_GEOLOCATION dictionary
    pAggDimSel := pInfo.Slice.Selection.FindById("MDM_DICT_GEOLOCATION");
    pAggDimSel.SelectAll;
    // Determine term corresponding to the output variable
    pMethod.Result.TermInfo := pInfo;
    // Get the MDM_DICT_GEOLOCATION dictionary
    pDimInstance := pAggDimSel.Dimension;
    pDimModel := pDimInstance.Dimension;
    // Get dictionary calendar frequencies
    pDimLevels := pDimModel.Levels;
    // Get aggregation settings
    pAggregator := pMethod.Aggregator(pDimModel);
    // Get aggregation settings for specified dictionary frequency
    pLevelAgg := pAggregator.LevelAggregation(pDimLevels.Item(pDimLevels.Count - 2));
    // Specify aggregation calendar frequency
    pLevelAgg.Include(pDimLevels.Item(pDimLevels.Count - 1)) := True;
    // Set the aggregation method
    pLevelAgg.Operation := BasicAggregatorOperation.Count;
    // Specify that non-aggregated data is not saved
    pLevelAgg.PreserveExistingData := False;
    // Add filter for aggregation dimension
    pFilter := pMethod.Filter.Add(pDimModel);
    // Keep only first six dictionary elements in aggregation
    pFilterSelection := pDimInstance.CreateSelection;
    For i := 0 To 5 Do
        pFilterSelection.SelectElement(i, False);
    End For;
    pFilter.AggregationSelection := pFilterSelection;
    // Add advanced filtering
    pFilter.AdvancedFilter.Clear;
    pAdvancedFilterCondition := pFilter.AdvancedFilter.Add;
    // Specify that only the elements are aggregated, which
    // value of the ISCAPITAL attribute is set to True
    pAdvancedFilterCondition.Attribute := pDimModel.Attributes.FindById("ISCAPITAL");
    pAdvancedFilterCondition.Operator_ := MsAdvancedFilterConditionOperator.Equal;
    pAdvancedFilterCondition.Value := True;
    // Save changes
    (pModel As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the model is configured to calculate matrix aggregation.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    pMsKey: uinteger;
    pModel: IMsModel;
    pTransform: IMsFormulaTransform;
    pFormula: IMsFormula;
    pMethod: IMsMatrixAggregationTransform;
    pInfo: IMsFormulaTermInfo;
    pAggregator: IBasicMatrixAggregator;
    pLevelAgg: IBasicMatrixLevelAggregator;
    pDimModel: IDimensionModel;
    pDimInstance: IDimInstance;
    pDimLevels: IDimLevels;
    pAggDimSel, pFilterSelection: IDimSelection;
    pFilter: IMsAggregationFilter;
    pAdvancedFilterCondition: IMsDimIteratorAdvancedFilterCondition;
    i: Integer;
Begin
    // Get current repository
    mb := Params.Metabase;
    // Get modelling container key
    pMsKey := mb.GetObjectKeyById("MS");
    // Get the model
    pModel := mb.ItemByIdNamespace["MODEL_MATRIXAGGREGATION", pMsKey].Edit() As IMsModel;
    // Get model calculation parameters
    pTransform := pModel.Transform;
    // Get model calculation method
    pFormula := pTransform.FormulaItem[0];
    // Change model calculation method for matrix aggregation
    pFormula.Kind := MsFormulaKind.mfkMatrixAggregation;
    // Get matrix aggregation calculation parameters
    pMethod := pFormula.Method As IMsMatrixAggregationTransform;
    // Create term
    pInfo := pTransform.CreateTermInfo();
    pInfo.Slice := pTransform.Outputs.Item[0].Slices.Item[0];
    // Get selection that is set by dimension that id based on the MDM_DICT_GEOLOCATION dictionary
    pAggDimSel := pInfo.Slice.Selection.FindById("MDM_DICT_GEOLOCATION");
    pAggDimSel.SelectAll();
    // Determine term corresponding to the output variable
    pMethod.Result.TermInfo := pInfo;
    // Get the MDM_DICT_GEOLOCATION dictionary
    pDimInstance := pAggDimSel.Dimension;
    pDimModel := pDimInstance.Dimension;
    // Get dictionary calendar frequencies
    pDimLevels := pDimModel.Levels;
    // Get aggregation settings
    pAggregator := pMethod.Aggregator[pDimModel];
    // Get aggregation settings for specified dictionary frequency
    pLevelAgg := pAggregator.LevelAggregation[pDimLevels.Item[pDimLevels.Count - 2]];
    // Specify aggregation calendar frequency
    pLevelAgg.Include[pDimLevels.Item[pDimLevels.Count - 1]] := True;
    // Set the aggregation method
    pLevelAgg.Operation := BasicAggregatorOperation.baoCount;
    // Specify that non-aggregated data is not saved
    pLevelAgg.PreserveExistingData := False;
    // Add filter for aggregation dimension
    pFilter := pMethod.Filter.Add(pDimModel);
    // Keep only first six dictionary elements in aggregation
    pFilterSelection := pDimInstance.CreateSelection();
    For i := 0 To 5 Do
        pFilterSelection.SelectElement(i As uinteger, False);
    End For;
    pFilter.AggregationSelection := pFilterSelection;
    // Add advanced filtering
    pFilter.AdvancedFilter.Clear();
    pAdvancedFilterCondition := pFilter.AdvancedFilter.Add();
    // Specify that only the elements are aggregated, which
    // value of the ISCAPITAL attribute is set to True
    pAdvancedFilterCondition.Attribute := pDimModel.Attributes.FindById("ISCAPITAL");
    pAdvancedFilterCondition.Operator := MsAdvancedFilterConditionOperator.msafcoEqual;
    pAdvancedFilterCondition.Value := True;
    // Save changes
    (pModel As IMetabaseObject).Save();
End Sub;

See also:

IMsMatrixAggregationTransform