IMsFormulaTransform.CreateSelector

Syntax

CreateSelector: IMsFormulaTransformSelector;

Description

The CreateSelector method creates an object containing properties for selecting the variable slice, by which the calculation method is set up.

Example

Sub Main;

Var

MB: IMetabase;

CrInf: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

Model: IMsModel;

Trans: IMsFormulaTransform;

VarTrans: IMsFormulaTransformVariable;

Tree: IMsFormulaTransformSlicesTree;

Slice: IMsFormulaTransformSlice;

Selector: IMsFormulaTransformSelector;

Formula: IMsFormula;

Linear: IMsLinearRegressionTransform;

Varr: IMsVariable;

TransVar: IMsFormulaTransformVariable;

Begin

MB := MetabaseClass.Active;

CrInf := Mb.CreateCreateInfo;

CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;

CrInf.Id := "New_LinReg";

CrInf.Name := "New_LinReg";

CrInf.Parent := Mb.ItemById("KONT_MODEL");

CrInf.Permanent := False;

MObj := Mb.CreateObject(CrInf).Edit;

Model := MObj As IMsModel;

Trans := Model.Transform;

//adding output variable

Varr := MB.ItemByIdNamespace("Var_11", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;

Model.Output.Add(Varr);

VarTrans := Trans.Outputs.Item(0);

Tree := VarTrans.SlicesTree(VarTrans);

Slice := Tree.CreateSlice(1);

Selector := Model.Transform.CreateSelector;

Selector.Slice := Slice;

Formula := Model.Transform.Transform(Selector);

Formula.Kind := MsFormulaKind.LinearRegression;

Formula.Level := DimCalendarLevel.Year;

//transfer to parameters configuration of the linear regression

Linear := Formula.Method As IMsLinearRegressionTransform;

Varr := MB.ItemByIdNamespace("Var_Factor", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;

//adding a factor

Model.Input.Add(Varr);

TransVar := Model.Transform.Inputs.Item(0);

Linear.Explanatories.Add.Expression.AsString := Model.Transform.SliceToTerm(TransVar.SlicesTree(VarTrans).CreateSlice(1), "");

MObj.Save;

End Sub Main;

After executing the example, a new model is created in the modeling container. For calculating the model the method of linear regression is used. The output variable and one factor are set for the model.

See also:

IMsFormulaTransform