ILanerSeries.AddCalculateSerieAsSource

Syntax

AddCalculateSerieAsSource(
    Factor: IRubricatorFactor;
    [RevisionKey: Integer = -1;]
    [ScenarioKey: Integer = -1;]
    [Index: Integer = -1]
): ILanerCalculateSerie;

Parameters

Factor. The series that will be a data source for calculated series.

RevisionKey. The key of the revision, which data must be contained in the series.

ScenarioKey. The key of the scenario, which data must be loaded.

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

Description

The AddCalculateSerieAsSource method adds a calculated series based on the specified series.

Comments

If the RevisionKey parameter has the -1 value, data for the last revision is taken.

If the time series database is a non-version one, the value of the RevisionKey parameter is ignored. The version is returned with the IRubricator.KeepHistory property.

If the ScenarioKey parameter has the -1 value, data is loaded by the Fact scenario.

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, Express, Laner, Metabase and Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    WbkObj: IMetabaseObject;
    EaxAn: IEaxAnalyzer;
    Laner: ILaner;
    Series: ILanerSeries;
    CalcSerie, Serie: ILanerCalculateSerie;
    tr: IMsFormulaTransform;
    OutVar, InpVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    Selector: IMsFormulaTransformSelector;
    Formula: IMsFormula;
    Determ: IMsDeterministicTransform;
    TermInfo: IMsFormulaTermInfo;
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 in the workbook
    CalcSerie := Series.Item(0As ILanerCalculateSerie;
    // Create a calculated series based on the obtained series
    Serie := Series.AddCalculateSerieAsSource(CalcSerie.Source, -1, -10);
    // Set series name
    Serie.Name := Serie.SourceStub.Name + " + 10";
    // Set series calculation method
    Serie.UseTransform := True;
    tr := Serie.Transform.Transform As IMsFormulaTransform;
    OutVar := tr.Outputs.Item(0);
    Slice := OutVar.Slices.Add(Null);
    Selector := tr.CreateSelector;
    Selector.Slice := Slice;
    // Set calculation formula
    Formula := tr.Transform(Selector);
    Formula.Kind := MsFormulaKind.Deterministic;
    Determ := Formula.Method As IMsDeterministicTransform;
    InpVar := tr.Inputs.Add(Serie.SourceStub);
    Slice := InpVar.Slices.Add(Null);
    TermInfo := tr.CreateTermInfo;
    TermInfo.Slice := Slice;
    Determ.Expression.AsString := TermInfo.TermInnerText + " + 10";
    // Save changes
    WbkObj.Save;
End Sub UserProc;

After executing the example the calculated series is added to the beginning of the workbook based on the data from the first workbook series.

See also:

ILanerSeries