IMsUnitInfo.BaseUnit

Syntax

BaseUnit: Integer

Description

The BaseUnit property returns index of base unit.

Comments

The BaseUnit index corresponds to the element index in the measures and units dictionary. The dictionary is returned by the IMsUnitInfo.UnitsDimension property.

If BaseUnit returns -1, the base unit is not determined.

Example

Executing the example requires that the repository contains a time series database with the FC identifier. The modeling container of this time series database should contain a model of determinate equation with the DETERM identifier. Measurement units dictionary is not a mandatory attribute of the time series database.

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

Sub UserProc;
Var
    Mb: IMetabase;
    Cat: IRubricator;
    MsDesc: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Formula: IMsFormula;
    Determ: IMsDeterministicTransform;
    i: Integer;
    Operands: IMsFormulaTermList;
    UnitInfo: IMsUnitInfo;
    Elements: IDimElements;
    Term: IMsFormulaTerm;
Begin
    Mb := MetabaseClass.Active;
    Cat := Mb.ItemById("FC").Bind As IRubricator;
    MsDesc := Cat.ModelSpace;
    Model := mb.ItemByIdNamespace("DETERM", MsDesc.Key).Bind As IMsModel;
    Formula := Model.Transform.FormulaItem(0);
    Determ := Formula.Method As IMsDeterministicTransform;
    Operands := Determ.Operands;
    UnitInfo := Operands.UnitInfo;
    If UnitInfo.Unit <> -1 Then
        Debug.WriteLine("All model operands have common units: ");
        Elements := UnitInfo.UnitsDimension.Elements;
        Debug.WriteLine("  - base unit: " + Elements.Name(UnitInfo.BaseUnit));
        Debug.WriteLine("  - measurement unit: " + Elements.Name(UnitInfo.Unit));
        Debug.WriteLine("  - measure: " + Elements.Name(UnitInfo.Measure));
    Else
        Debug.WriteLine("Model operands have different units:");
        For i := 0 To Operands.Count - 1 Do
            Term := Operands.Item(i);
            Debug.WriteLine("  " + Term.TermToText);
            UnitInfo := Term.UnitInfo;
            Elements := UnitInfo.UnitsDimension.Elements;
            Debug.WriteLine("  - base unit: " + Elements.Name(UnitInfo.BaseUnit));
            Debug.WriteLine("  -  unit: " + Elements.Name(UnitInfo.Unit));
            Debug.WriteLine("  - measure: " + Elements.Name(UnitInfo.Measure));
            Debug.WriteLine("");
        End For;
    End If;
End Sub UserProc;

Example execution result: if all the operands of the determinate equation have common unit, its information is displayed in the console window. If the operands have different units, the information for each unit is displayed.

See also:

IMsUnitInfo