IMsFormulaTransformVariable.AttributeId

Syntax

AttributeId: String;

Description

The AttributeId property determines an identifier for the variable attribute.

Comments

This property is relevant if the MsFormulaTransformVariableKind.Attribute property is set to the IMsFormulaTransformVariable.Kind value, that is, the variable is built in the data source and attribute. The equal variables are designed to be used in expressions. If the attribute is not set, the variable is considered as a set of values, if the attribute is set, it is considered as the value of attribute. In AttributeId the factor attribute identifier or the observations attribute identifier can be specified.

If the attribute is determined, it is possible to specify the constant value of dictionary, to which this attribute refers. To do this, it is necessary to add a dictionary to the objects collection of model parameters (use the IFormulaTransform.ObjectList.Add() method). Then receive a key of the added object, generate the internal view of term for the dictionary on its basis and pass it into the expression. Term must have the following format: @__<object_key>.

Example

Executing the example requires that the repository contains a time series database with the FC identifier. A model with the MODEL_ATTR identifier must be available in the modeling container of this database. The model is calculated as determinate equation. Also, before executing the procedure it is necessary to add links to the Ms, Cubes, Rds, Metabase system assemblies.

Sub UserProc;

Var

Mb: IMetabase;

RubrDescr: IMetabaseObjectDescriptor;

Rubr: IRubricator;

MsDescr: IMetabaseObjectDescriptor;

Model: IMsModel;

Transform: IMsFormulaTransform;

TransformVarables: IMsFormulaTransformVariables;

TransVar: IMsFormulaTransformVariable;

FactsAttrs: IMetaAttributes;

Attr: IMetaAttribute;

DictDescr: IMetabaseObjectDescriptor;

ObjList: IMsTransformObjectList;

TransfObj: IMsTransformObject;

TermTrue, TermFalse: String;

Determ: IMsDeterministicTransform;

Expr: IExpression;

FormulaTerm: IMsFormulaTerm;

Begin

Mb := MetabaseClass.Active;

RubrDescr := Mb.ItemById("FC");

Rubr := RubrDescr.Bind As IRubricator;

MsDescr := Rubr.ModelSpace;

Model := Mb.ItemByIdNamespace("MODEL_ATTR", MsDescr.Key).Edit As IMsModel;

Transform := Model.Transform;

TransformVarables := Transform.Outputs;

TransVar := TransformVarables.Item(0);

TransVar.AttributeId := "UNIT";

FactsAttrs := Rubr.Facts.Attributes;

Attr := FactsAttrs.FindById("UNIT");

DictDescr := Attr.ValuesObject;

ObjList := Transform.ObjectList;

If ObjList.Count > 0

Then ObjList.Clear;

End If;

TransfObj := ObjList.Add(DictDescr);

TermTrue := "@__" + TransfObj.Key.ToString + ":3433"; //3433 - Billions of National Currency

TermFalse := "@__" + TransfObj.Key.ToString + ":3549"; //3549 - National Currency

Determ := Transform.FormulaItem(0).Method As IMsDeterministicTransform;

Expr := Determ.Expression;

Expr.AsString := "";

FormulaTerm := Determ.Operands.Item(0);

Expr.AsString := "iif(" + FormulaTerm.TermToText + "=3433," + TermTrue + "," + TermFalse + ")";

If Not (Expr.Valid)

Then Debug.WriteLine(Expr.ErrorInfo.ErrorMessage);

Else (Model As IMetabaseObject).Save;

End If;

End Sub UserProc;

After executing the example the output variable of model is used for loading in it the values of the UNIT attribute (units). The calculation formula of the determinate equation is changed to the following one: if measurement units of the first input variable are Billions of National Currency, measurement units of the output variable are replaced with Billions of National Currency. In case measurement units of the first input variable are other than Billions of National Currency, measurement units of the output variable are changed to National Currency.

See also:

IMsFormulaTransformVariable