UserFormat: String;
UserFormat: string;
The UserFormat property determines name format for calculated series.
The property value is considered if ILanerSerie.UserName is set to False.
The property supports the use of the %s parameter, which is replaced with input series name on generating the name. For example, UserFormat is set to Abs(%s), an the input series is named Albania|BCA. Therefore, the Abs(Albania|BCA) name will be used for the calculated series..
Executing the example requires that the repository contains a workbook with the WORKBOOK_CALC_SERIES identifier that contains several data series.
Add links to the Cubes, Dimensions, Express, Laner, Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
WbkObj: IMetabaseObject;
EaxAn: IEaxAnalyzer;
Laner: Ilaner;
UsingSerie: ILanerSerie;
NewSerie: ILanerCalculateSerie;
Transf: 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_CALC_SERIES").Edit;
EaxAn := WbkObj As IEaxAnalyzer;
// Get object for executing operations with workbook
Laner := EaxAn.Laner;
// Get the first series in the workbook
UsingSerie := Laner.Series.Item(0) As ILanerSerie;
// Create a calculated series in the workbook
NewSerie := Laner.Series.AddCalculateSerie("");
// Set format of calculated series name
NewSerie.UserName := False;
NewSerie.UserFormat := "Logarithm (%s)";
// Set parameters of calculated series calculation
Transf := NewSerie.Transform;
Transf.AddInputVariable(UsingSerie.Stub);
ms := Transf.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;
Formula.Level := DimCalendarLevel.Year;
Det := Formula.Method As IMsDeterministicTransform;
TransformVar := ms.Inputs.Add(UsingSerie.Stub);
Slice := TransformVar.Slices.Add(Null);
Term1 := Det.Operands.Add(Slice);
Det.Expression.AsString := "Log(" + Term1.TermToInnerText + ", 2)";
// Calculate the series
NewSerie.Calculate;
// Save changes in the workbook
WbkObj.Save;
End Sub UserProc;
After executing the example the calculated series is added to the workbook, the series name is formed by the following format: Logarithm (%s), where %s is input series name.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Laner;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
WbkObj: IMetabaseObject;
EaxAn: IEaxAnalyzer;
Laner: Ilaner;
UsingSerie: ILanerSerie;
NewSerie: ILanerCalculateSerie;
Transf: IFormulaTransformModel;
ms: IMsFormulaTransform;
TransformVar: IMsFormulaTransformVariable;
Coord: IMsFormulaTransformCoord;
Slice: IMsFormulaTransformSlice;
selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
Det: IMsDeterministicTransform;
Term1: IMsFormulaTerm;
Begin
// Get workbook
mb := Params.Metabase;
WbkObj := mb.ItemById["WORKBOOK_CALC_SERIES"].Edit();
EaxAn := WbkObj As IEaxAnalyzer;
// Get object for executing operations with workbook
Laner := EaxAn.Laner;
// Get the first series in the workbook
UsingSerie := Laner.Series.Item[0] As ILanerSerie;
// Create a calculated series in the workbook
NewSerie := Laner.Series.AddCalculateSerie("", DimCalendarLevel.dclNone, -1);
// Set format of calculated series name
NewSerie.UserName := False;
NewSerie.UserFormat := "Logarithm (%s)";
// Set parameters of calculated series calculation
Transf := NewSerie.Transform;
Transf.AddInputVariable(UsingSerie.Stub);
ms := Transf.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.mfkDeterministic;
Formula.Level := DimCalendarLevel.dclYear;
Det := Formula.Method As IMsDeterministicTransform;
TransformVar := ms.Inputs.Add(UsingSerie.Stub);
Slice := TransformVar.Slices.Add(Null);
Term1 := Det.Operands.Add(Slice);
Det.Expression.AsString := "Log(" + Term1.TermToInnerText() + ", 2)";
// Calculate the series
NewSerie.Calculate();
// Save changes in the workbook
WbkObj.Save();
End Sub;
See also: