IMsBranchConditionExpression.Transform

Syntax

Transform: IMsFormulaTransform;

Description

The Transform property returns parameters of complex condition of calculation.

Comments

By default, parameters contain one formula with annual frequency. To get the formula, use the IMsFormulaTransform.FormulaItem property. After creating the formula, it will be automatically decomposed and set into the IMsBranchConditionExpression.Expression property.

Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier, which contains models with the USER_MODEL, DEFAULT_MODEL identifiers and a metamodel with the USER_META_MODEL identifier. The metamodel must contain an integer parameter named indicator_param.

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

Sub UserTransformation;
Var
    pMetabase: IMetabase;
    pMSKey: Integer;
    pMeta: IMsMetaModel;
    pBranch: IMsCalculationChainBranch;
    pModel_a, pModel_b: IMsModel;
    pCase: IMsBranchCase;
    pCond: IMsBranchConditionExpression;
    pTransf: IMsFormulaTransform;
    pMethod: IMsDeterministicTransform;
Begin
    pMetabase := MetabaseClass.Active;
    //Get modeling container key
    pMSKey := pMetabase.GetObjectKeyById("MODEL_SPACE");
    // Get metamodel
    pMeta := pMetabase.ItemByIdNamespace("USER_META_MODEL", pMSKey).Edit As IMsMetaModel;
    // Clear calculation chain of metamodel
    pMeta.CalculationChain.Clear;
    // Create a condition of metamodel calculation
    pBranch := pMeta.CalculationChain.AddBranch("Calculation condition");
    // Set calendar frequency of condition
    pBranch.Level := DimCalendarLevel.Year;
    // Get the DEFAULT_MODEL model
    pModel_a := pMetabase.ItemByIdNamespace("DEFAULT_MODEL", pMSKey).Bind As IMsModel;
    // Add model to condition
    pBranch.DefaultContents.AddModel(pModel_a);
    // Get the USER_MODEL model
    pModel_b := pMetabase.ItemByIdNamespace("USER_MODEL", pMSKey).Bind As IMsModel;
    // Create a new branch of condition
    pCase := pBranch.CaseList.Add;
    // Add the USER_MODEL model to new branch
    pCase.Contents.AddModel(pModel_b);
    // Create a condition of branch calculation
    pCond := pCase.Conditions.Add(MsBranchConditionType.Expression) As IMsBranchConditionExpression;
    pTransf := pCond.Transform;
    pMethod := pTransf.FormulaItem(0).Method As IMsDeterministicTransform;
    pMethod.Expression.AsString := "{indicator_param[t]} = 3";
    // Save metamodel 
    (pMeta As IMetabaseObject).Save;
End Sub UserTransformation;

After executing the example the calculation condition will be added to the metamodel: the value of the metamodel parameter must be equal to three. On calculating the transformation problem the following condition is checked: if it is satisfied, the USER_MODEL model is calculated; if it is not satisfied, the DEFAULT_MODEL is calculated.

See also:

IMsBranchConditionExpression