LevelParam: String;
The LevelParam property determines a parameter that sets method calculation frequency.
To directly set calculation frequency, use the IMsFormula.Level property.
Executing the example requires that the repository contains a modeling container with the MS identifier. The container should contain a metamodel with the META_LEVELPARAM identifier. The metamodel calculates a model with the MODEL_LEVELPARAM identifier.
Add links to the Dimensions, Metabase, Ms, Transform system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
Metamodel: IMsMetaModel;
Params: IMsModelParams;
Param: IMsModelParam;
Model: IMsModel;
Formula: IMsFormula;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
Metamodel := mb.ItemByIdNamespace("META_LEVELPARAM", MsKey).Edit As IMsMetaModel;
// Get metamodel parameters collection
Params := Metamodel.Params;
// Clear metamodel parameters collection
Params.Clear;
// Add a new parameter
Param := Params.Add;
// Determine parameter type - frequency
Param.ParamType := TsParamType.Frequency;
// Set default value - annual frequency
Param.DefaultValue := DimCalendarLevelSet.Year;
// Set parameter name and identifier
Param.Name := "Calculation frequency";
Param.Id := "Formula_Level";
// Save changes of the metamodel
(Metamodel As IMetabaseObject).Save;
// Get the model
Model := mb.ItemByIdNamespace("MODEL_LEVELPARAM", MsKey).Edit As IMsModel;
// Get model calculation method
Formula := Model.Transform.FormulaItem(0);
// Determine that model calculation frequency will be determined by the following parameter
Formula.LevelParam := "Formula_Level";
// Save changes in the model
(Model As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the model with the MODEL_LEVELPARAM identifier will be calculated by the frequency that is set by the Formula_Level parameter.
See also: