ILanerSeries.AddCalculateSerie

Syntax

AddCalculateSerie(
    SerieName: String;
    [Level: DimCalendarLevel = -1;]
    [Index: Integer = -1]
): ILanerCalculateSerie;

Parameters

SerieName. The name of the series to be added.

Level. The calendar frequency of the series to be added.

Index. Index of the position, into which the series must be added.

Description

The AddCalculateSerie method adds a calculated series.

Comments

If the Level parameter is not set, or its value is -1, the calendar frequency set in the series formula IMsFormula.Level is used.

If the interpolation or the collapse method is used for the calculation of the series values , the Level parameter must be set.

If the Index parameter has the -1 value, the calculated series is added to the end of the series collection.

Example

Executing the example requires a workbook with the WORKBOOK_SERIES identifier that contains several series.

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

Sub UserProc;
Var
    mb: IMetabase;
    WbkObj: IMetabaseObject;
    EaxAn: IEaxAnalyzer;
    Laner: ILaner;
    Series: ILanerSeries;
    UsingSerie: ILanerSerie;
    NewSerie: ILanerCalculateSerie;
    Trasss: IFormulaTransformModel;
    ms: IMsFormulaTransform;
    TransformVar: IMsFormulaTransformVariable;
    Coord: IMsFormulaTransformCoord;
    Slice: IMsFormulaTransformSlice;
    selector: IMsFormulaTransformSelector;
    Formula: IMsFormula;
    Det: IMsDeterministicTransform;
    Term1: IMsFormulaTerm;
Begin
    // Get workbook
    mb := MetabaseClass.Active;
    WbkObj := mb.ItemById("WORKBOOK_SERIES").Edit;
    EaxAn := WbkObj As IEaxAnalyzer;
    Laner := EaxAn.Laner;
    // Get workbook series
    Series := Laner.Series;
    // Get the first series of wokbook
    UsingSerie := Series.Item(0As ILanerSerie;
    // Add calculated series
    NewSerie := Laner.Series.AddCalculateSerie("", DimCalendarLevel.Year, 0);
    // Set parameters of series name generation
    NewSerie.UserName := False;
    NewSerie.UserFormat := ("Ln(%s)");
    // Set series calculation parameters
    NewSerie.UseTransform := True;
    Trasss := NewSerie.Transform;
    // Set input variable
    Trasss.AddInputVariable(UsingSerie.Stub);
    // Set calculation formula
    ms := Trasss.Transform As IMsFormulaTransform;
    TransformVar := ms.Outputs.Item(0);
    Coord := ms.CreateCoord(TransformVar);
    Slice := TransformVar.Slices.Add(Null);
    Selector := ms.CreateSelector;
    Selector.Slice := Slice;
    Formula := ms.Transform(Selector);
    Formula.Kind := MsFormulaKind.Deterministic;
    Det := Formula.Method As IMsDeterministicTransform;
    TransformVar := ms.Inputs.Add(UsingSerie.Stub);
    Slice := TransformVar.Slices.Add(Null);
    Term1 := Det.Operands.Add(Slice);
    Det.Expression.AsString := "Ln(" + Term1.TermToInnerText + ")";
    // Save changes
    WbkObj.Save;
End Sub UserProc;

After executing the example the calculated series that calculates natural logarithm of the first series is added to the workbook.

See also:

ILanerSeries