IMsCollapseTransformationMethod.CollapseType

Syntax

CollapseType: MsCollapseType;

Description

The CollapseType property determines the aggregation method that must be used at term transformation.

Example

Executing the example requires that the repository contains a workbook with the WORKBOOK identifier. The workbook should contain a time series database. This database should include an indicator with the 1 key that contains quarterly data.

Add links to the Cubes, Dimensions, Express, Laner, Metabase, Ms, and Rds system assemblies.

Sub Main;
Var
    MB: IMetabase;
    Workbook: IEaxAnalyzer;
    Laner: ILaner;
    Factor: IRubricatorFactor;
    Series: ILanerSeries;
    RubrIn: IRubricatorInstance;
    Serie: ILanerCalculateSerie;
    TransformModel: IFormulaTransformModel;
    CalcSerie: ILanerCalculateSerie;
    Selector: IMsFormulaTransformSelector;
    Slice: IMsFormulaTransformSlice;
    MDic: IMetaDictionary;
    MetaAttr: IMetaAttribute;
    MsMetaAttributeValue: IMsMetaAttributeValue;
    Formula: IMsFormula;
    FormulaTransform: IMsFormulaTransform;
    Det: IMsDeterministicTransform;
    Rubricator: IRubricator;
    Info: IMsFormulaTermInfo;
    Term: IMsFormulaTerm;
    TermMeth: IMsFormulaTermTransformationMethod;
    Collapse: IMsCollapseTransformationMethod;
Begin
    // Get the current repository
    MB := MetabaseClass.Active;
    // Get workbook
    Workbook := MB.ItemById("WORKBOOK").Edit As IEaxAnalyzer;
    // Get working area of indicators directory
    Laner := Workbook.Laner;
    // Get the collection of working area series
    Series := Laner.Series;
    // Get time series database data
    RubrIn := Laner.RubricatorInstance;
    // Get a time series of indicator with the 1 key
    Factor := RubrIn.GetFactData(1).Factor;
    // Add a calculated series based on a time series
    Serie := Series.AddCalculateSerieAsSource(Factor);
    // Add a calculated series named Collapse
    CalcSerie := Series.AddCalculateSerie("Collapse");
    // Set up calculated series parameters
    TransformModel := CalcSerie.Transform;
    TransformModel.AddInputVariable(Serie.Stub);
    // Set up calculation method parameters
    FormulaTransform := TransformModel.Transform As IMsFormulaTransform;
    Selector := FormulaTransform.CreateSelector;
    Slice := FormulaTransform.Outputs.Item(0).Slices.Add(Null);
    Selector.Slice := Slice;
    Formula := FormulaTransform.Transform(Selector);
    Formula.Kind := MsFormulaKind.Deterministic;
    Formula.Level := DimCalendarLevel.Year; 
    Det := Formula.Method As IMsDeterministicTransform;
    Slice := FormulaTransform.Inputs.Item(0).Slices.Add(Null);
    Rubricator := Laner.RubricatorInstance.Rubricator;
    MDic := Rubricator.Facts;
    MetaAttr := MDic.Attributes.FindByKind(MetaAttributeKind.CalendarLevel);
    MsMetaAttributeValue := Slice.MetaAttributeValueList.Add(MetaAttr);
    MsMetaAttributeValue.Value := DimCalendarLevelSet.Quarter;
    Term := Det.Operands.Add(Slice);
    Info := Term.TermInfo;
    TermMeth := Info.CreateTermTransformationMethod(MsTermTransformationType.Collapse);
    Collapse := TermMeth As IMsCollapseTransformationMethod;
    Collapse.CollapseType := MsCollapseType.Maximum;
    Info.TermTransformationMethod := Collapse;
    Det.Expression.AsString := Term.TermToInnerText;
    // Save changes
    (Workbook As IMetabaseObject).Save;
End Sub Main;

After executing the example a new Collapse series that displays the data of the specified indicator is added in the workbook. Based on it, the series calculated by the Collapse method is created. Data is aggregated from quarterly to annual frequency. Aggregation method is Maximum.

See also:

IMsCollapseTransformationMethod