IMsFormulaTransformVariables.AddAttributeVariable

Syntax

AddAttributeVariable(Value: IVariableStub; AttributeId: String): IMsFormulaTransformVariable;

Parameters

Value. Variable data source.

AttributeId. Identifier of the attribute that is a base for the variable.

Description

The AddAttributeVariable method adds a variable to the collection based on attribute.

Comments

Variables, based on the attribute, are designed to be used in expressions. To determine the method of the attribute value setting, use IMsMetaAttributeValue.Kind.

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. 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;

Stub: IVariableStub;

TransVar: IMsFormulaTransformVariable;

Slice: IMsFormulaTransformSlice;

AttrValList: IMsMetaAttributeValueList;

AttrVal: IMsMetaAttributeValue;

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;

Stub := RubrDescr.Bind As IVariableStub;

TransVar := TransformVarables.AddAttributeVariable(Stub, "UNIT");

Slice := TransformVarables.Item(0).Slices.Item(0);

AttrValList := Slice.MetaAttributeValueList;

AttrVal := AttrValList.FindById("UNIT");

AttrVal.Kind := MsMetaAttributeValueType.Unspecified;

(Model As IMetabaseObject).Save;

End Sub UserProc;

After executing the example the input variable, based on the UNIT time series attribute (measurement units), is added for the model. Attribute value is non-specified. Thus, on calculating the model, values of this attribute for the output variables are checked. If the values coincide, this value is recorded to the attribute of output variable, otherwise the attribute value is not changed.

See also:

IMsFormulaTransformVariables