IMsFormulaTermInfo.SetDateByLevel

Syntax

SetDateByLevel(Value: DateTime; Level: DimCalendarLevel);

Parameters

Value. The date, to which expression element value must be fixed.

Level. Calendar frequency, to which expression element value must be fixed.

Description

The SetDateByLevel method fixes date and calendar frequency for expression element.

Comments

Date and calendar frequency can be fixed if expression element is a value for the specified date, that is, the IMsFormulaTermInfo.Type property is set to MsFormulaTermType.Date.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier that contains the determinate equation model with the MODEL_DATEBYLEVEL identifier. This model must contain one or more factors.

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

Sub UserProc;
Var
    mb: IMetabase;
    MSKey: Integer;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    Determ: IMsDeterministicTransform;
    Info: IMsFormulaTermInfo;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modelling container key
    MSKey := mb.GetObjectKeyById("MS");
    // Get the model
    Model := mb.ItemByIdNamespace("MODEL_DATEBYLEVEL", MSKey).Edit As IMsModel;
    // Get model parameters
    Transform := Model.Transform;
    // Get calculation parameters of determinate equation
    Determ := Transform.FormulaItem(0).Method As IMsDeterministicTransform;
    Info := Determ.Operands.Item(0).TermInfo;
    // Set type of expression element: date-specific value
    Info.Type := MsFormulaTermType.Date;
    // Set date for expression element
    Info.SetDateByLevel(DateTime.Parse("01.01.2015"), DimCalendarLevel.Year);
    // Insert element to equation
    Determ.Expression.AsString := Info.TermInnerText;
    // Save changes
    (Model As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the date 2015 year is fixed for model factor.

See also:

IMsFormulaTermInfo