IMsFormulaTransform.Transform

Syntax

Transform(Selector: IMsFormulaTransformSelector): IMsFormula;

Parameters

Selector. The object, which determines the slice of the variable, by which it is necessary to set up calculation method parameters.

Description

The Transform property returns the object allowing to set up calculation method parameters.

Comments

If the output variable contains additional dimensions, there is a possibility for each slice to determine its own calculation method.

Example

Executing the example requires that the repository contains a modeling container with the KONT_MODEL identifier.

Add links to the Metabase and Ms system assemblies.

Sub UserProc;
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;
    //add an output variable
    Varr := MB.ItemByIdNamespace("Var_11",MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
    Model.Output.Add(Varr);
    For i := 0 To Varr.Dimensions.Count- 1 Do
        Trans.DimensionTransparent(Model.Transform.Outputs.Item(0),Varr.Dimensions.Item(i).Model) := True;
    End For;
    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;
    //proceed to setting up linear regression parameters
    Linear := Formula.Method As IMsLinearRegressionTransform;
    Varr := MB.ItemByIdNamespace("Var_Factor",MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
    //add 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 UserProc;

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. If the output variable has additional dimensions, they will use common specification of calculation.

See also:

IMsFormulaTransform