IMsFormulaTermInfo.SetDate

Syntax

SetDate(Value: DateTime; DateFormat: String);

Parameters

Value. Date, which needs to be fixed for this term.

DateFormat. Date format, according to which the fixation is made.

Description

The SetDate method fixes the date for the term.

Comments

When a method is called, the IMsFormulaTermInfo.Type property is automatically set to MsFormulaTermType.Date, and the value of the point corresponding to this date will be used as a term value during model calculation.

Examples of formats, which the DateFormat parameter may take:

Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier. The container has the VAR variable, which will be used as a modeling one, and the VAR_F variable used as a factor.

Add links to the Cubes, Dimensions, Metabase, Ms system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Kont: IMetabaseObjectDescriptor;
    CrInf: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Model: IMsModel;
    Trans: IMsFormulaTransform;
    VarTrans: IMsFormulaTransformVariable;
    Tree: IMsFormulaTransformSlicesTree;
    Slice: IMsFormulaTransformSlice;
    Selector: IMsFormulaTransformSelector;
    Formula: IMsFormula;
    NonLinear: IMsNonLinearRegressionTransform;
    Varr: IVariableStub;
    TransVar: IMsFormulaTransformVariable;
    TermX1, TermX2: IMsFormulaTerm;
    TermX1Info, TermX2Info: IMsFormulaTermInfo;
Begin
    MB := MetabaseClass.Active;
    Kont := Mb.ItemById("MODEL_SPACE");
    //creating model
    CrInf := Mb.CreateCreateInfo;
    CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
    CrInf.Id := MB.GenerateId("New_NonLinReg", Kont.Key);
    CrInf.Name := "New_NonLinReg";
    CrInf.Parent := Kont;
    MObj := Mb.CreateObject(CrInf).Edit;
    Model := MObj As IMsModel;
    Trans := Model.Transform;
    //adding output variable
    Varr := MB.ItemByIdNamespace("VAR", Kont.Key).Bind As IVariableStub;
    Trans.Outputs.Add(Varr);
    VarTrans := Trans.Outputs.Item(0);
    Tree := VarTrans.SlicesTree(VarTrans);
    Slice := Tree.CreateSlice(1);
    Selector := Trans.CreateSelector;
    Selector.Slice := Slice;
    Formula := Trans.Transform(Selector);
    Formula.Kind := MsFormulaKind.NonLinearRegression;
    Formula.Level := DimCalendarLevel.Year;
    NonLinear := Formula.Method As IMsNonLinearRegressionTransform;
    //adding factor
    Varr := MB.ItemByIdNamespace("VAR_F", Kont.Key).Bind As IVariableStub;
    Trans.Inputs.Add(Varr);
    TransVar := Trans.Inputs.Item(0);
    Slice := TransVar.SlicesTree(VarTrans).CreateSlice(1);
    //comparing the term to the slice in variable
    TermX1 := NonLinear.Operands.Add(Slice);
    TermX2 := NonLinear.Operands.Add(Slice);
    TermX1Info := TermX1.TermInfo;
    TermX2Info := TermX2.TermInfo;
    TermX2Info.Type := MsFormulaTermType.Date;
    TermX2Info.SetDate(DateTime.ComposeDay(200011), "YYYY");
    //creating equation
    NonLinear.Expression.AsString := "A0+" + TermX1Info.TermInnerText + "/" + TermX2Info.TermInnerText;
    MObj.Save;
End Sub UserProc;

After executing the example, a new model is created in the modeling container. The method of non-linear regression is used for model calculation. The output variable and one input variable is added into the model. To set up an equation, terms referring to the slice of the input variable will be created. On calculation of the model, the coordinate value, that corresponds to the year 2000, is substituted as the value of the second term.

See also:

IMsFormulaTermInfo | IMsFormulaTermInfo.Date