IMsVariable.DataFillType

Syntax

DataFillType: MsVariableDataFillType;

Description

The DataFillType property determines the method used to fill modeling variable with data.

Example

Executing the example requires that the repository contains a modeling container with the Kont_Model identifier. The container includes a modeling variable with the Var_1 identifier.

Sub Main;

Var

MB: IMetabase;

CrInfo: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

MsVar: IMsVariable;

Sampling: IMsVariableSampling;

//Cube with data of modeling variable

Cube: IAutoCube;

//For aggregation setup by the calendar

AggrManager: MatrixAggregatorManager;

IAggrManager: IMatrixAggregatorManager;

AggrModel: IMatrixAggregatorModel;

BasicAggregator: IBasicMatrixAggregator;

LevelBasicAggregator: IBasicMatrixLevelAggregator;

Dim: IAutoCubeDimension;

DimModel: IDimensionModel;

DimLvl: IDimLevels;

//For formula creation

Trans: IMsFormulaTransform;

VarTrans: IMsFormulaTransformVariable;

InputVar: IVariableStub;

Tree: IMsFormulaTransformSlicesTree;

Slice: IMsFormulaTransformSlice;

Selector: IMsFormulaTransformSelector;

Formula: IMsFormula;

Determ: IMsDeterministicTransform;

Term: IMsFormulaTerm;

TermInfo: IMsFormulaTermInfo;

s: string;

//For data loading

LoadSetting: IMsVariableLoadSettings;

DimFix: IMsProblemDimensionFix;

DimSS: IDimSelectionSet;

DimS: IDimSelection;

Period: IMsModelPeriod;

Begin

MB := MetabaseClass.Active;

CrInfo := MB.CreateCreateInfo;

CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MSVARIABLE;

CrInfo.Id := "Var_2";

CrInfo.Name := Variable #2;

CrInfo.Parent := MB.ItemById("Kont_Model");

MObj := MB.CreateObject(CrInfo).Edit;

MsVar := MObj As IMsVariable;

//Method of filling with data

MsVar.DataFillType := MsVariableDataFillType.Formula;

Sampling := MsVar.Sampling;

//Calculation step for the variable: Years and half-years

Sampling.Level(DimCalendarLevel.Year) := True;

Sampling.Level(DimCalendarLevel.HalfYear) := True;

Cube := MsVar.Cube;

//Parameters of aggregation by calendar levels

AggrManager := New MatrixAggregatorManager.Create;

IAggrManager := AggrManager As IMatrixAggregatorManager;

AggrModel := IAggrManager.CreateAggregator("BasicMatrixAggregator");

Dim := Cube.Dimensions.Calendar;

DimModel := Dim.Dimension;

DimLvl := DimModel.Levels;

//Aggregation for calendar dimension

AggrModel.Dimension := DimModel;

BasicAggregator := AggrModel As IBasicMatrixAggregator;

//The level for which aggregation is adjusted is Years level

LevelBasicAggregator := BasicAggregator.LevelAggregation(DimLvl.Item(0));

//Level, which values are used at aggregation is Half-years

LevelBasicAggregator.Include(DimLvl.Item(1)) := True;

//Aggregation method is Sum

LevelBasicAggregator.Operation := BasicAggregatorOperation.Sum;

Dim.Aggregator(Cube.Destinations.Item(0)) := AggrModel;

//Setting up the equation by which variable data is calculated

Trans := MsVar.Transform;

InputVar := MB.ItemByIdNamespace("Var_1", MB.ItemById("Kont_Model").Key).Bind As IMsVariableStub;

Trans.Inputs.Add(InputVar);

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

//Calculation step

Formula.Level := DimCalendarLevel.HalfYear;

//Calculation formula

Determ := Formula.Method As IMsDeterministicTransform;

Slice := Trans.Inputs.Item(0).Slices.Add(Null);

Determ.Operands.Add(Slice);

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

TermInfo := Term.TermInfo;

TermInfo.Lag := -1; //Lag

TermInfo.Inversion := MsInversion.DLog; //Transformation

Term.TermInfo := TermInfo;

s := Term.TermToInnerText + "*10";

Determ.Expression.AsString := s;

//Data loading by setting formula

LoadSetting := MsVar.CreateLoadSettings;

Period := LoadSetting.Period;

Period.IdentificationStartDate := DateTime.ComposeDay(2000, 1, 1);

Period.IdentificationEndDate := DateTime.ComposeDay(2010, 1, 1);

LoadSetting.ScenarioIncluded(-1) := True;

DimFix := LoadSetting.DimensionFix;

DimSS := DimFix.Selection;

For Each DimS In DimSS Do

DimS.SelectAll;

End For;

MsVar.Execute(LoadSetting);

MObj.Save;

End Sub Main;

After executing the example a modeling variable is created in the modeling container. The way of data filling is by formula. Two levels are presented in the variable frequency. They are Years and Half-years. For the Years level of calendar the aggregation is set: Half-year level data is summed. For formula composing one variable is added. The lag and transformation are set, after that the formula is composed. For specified period the data is loaded to the variable by the Fact dimension.

See also:

IMsVariable