AddCalculateSerieAsSource(
Factor: IRubricatorFactor;
[RevisionKey: Integer = -1;]
[ScenarioKey: Integer = -1;]
[Index: Integer = -1]
): ILanerCalculateSerie;
AddCalculateSerieAsSource(
Factor: Prognoz.Platform.Interop.Cubes.IRubricatorFactor;
RevisionKey: uinteger;
ScenarioKey: uinteger;
Index: integer
): Prognoz.Platform.Interop.Laner.ILanerCalculateSerie;
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.
The AddCalculateSerieAsSource method adds a calculated series based on the specified series.
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.
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(0) As ILanerCalculateSerie;
// Create a calculated series based on the obtained series
Serie := Series.AddCalculateSerieAsSource(CalcSerie.Source, -1, -1, 0);
// 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.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Laner;
…
Public Shared Sub Main(Params: StartParams);
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 := Params.Metabase;
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[0] As ILanerCalculateSerie;
// Create a calculated series based on the obtained series
Serie := Series.AddCalculateSerieAsSource(CalcSerie.Source, uinteger.MaxValue, uinteger.MaxValue, 0);
// 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.mfkDeterministic;
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;
See also: