ICompoundDimensionInstance.ComposeElement

Syntax

ComposeElement(Source: Integer; Elements: Array): Integer;

Parameters

Source - index of composite dictionary source, to which the element belongs.

Elements - array of the indexes of source-elements. Array dimension is determined by the number of fixed source dimensions Source.

Description

The ComposeElement method returns index of composite dictionary element by its sources.

If the element is not found, this method returns value -1.

Example

Executing the example requires that the repository contains a virtual cube with the Virt_Cube identifier.

Sub UserProc;
Var
    MB: IMetabase;
    Cube: IVirtualCube;
    Sources: IVirtualCubeSources;
    CDim: ICompoundDimension;
    CSource: ICompoundDimensionSource;
    CSel, Sel: IDimSelectionSet;
    FixInfo: ICubeDimensionFixInfo;
    Fix: ICubeDimensionFix;
    Params: IMetabaseObjectParamValues;
    CDimInst: ICompoundDimensionInstance;
    Instance: IDimInstance;
    Elements: IDimElements;
    Source, i: Integer;
    Arr: Array Of Integer;
Begin
    MB := MetabaseClass.Active;
    Cube := MB.ItemById("Virt_Cube").Bind As IVirtualCube;
    Sources := Cube.Sources;
    //Create selection to open composite dictionary
    CDim := Cube.FactDimension As ICompoundDimension;
    Sel := (New DimSelectionSetFactory.Create).CreateDimSelectionSet;
    CSel := (New DimSelectionSetFactory.Create).CreateDimSelectionSet;
    For Each CSource In CDim.Sources Do
        Sel.Clear;
        //Create selection according to fixed dimensions selection in data sources
        FixInfo := Sources.FindByKey(CSource.Key).FixInfo;
        For Each Fix In FixInfo Do
            If Fix.Selection.SelectedCount <> 0 Then
                Fix.Selection.CopyTo(Sel.Add(Fix.Instance), True);
            End If;
        End For;
        CSel.AddCompound(CSource.Key, Sel);
    End For;
    //Open composite dictionary
    Params := (CDim As IMetabaseObject).Params.CreateEmptyValues;
    Params.FindById("SELECTIONS").Value := CSel;
    CDimInst := (CDim As IMetabaseObject).Open(Params) As ICompoundDimensionInstance;
    //Get composite dictionary elements
    Instance := CDimInst As IDimInstance;
    Elements := Instance.Elements;
    //Index of the last data source
    Source := CDim.Sources.Count - 1;
    //Last data source
    CSource := CDim.Sources.Item(Source);
    //Array of element indexes for getting index of composite dictionary element
    Arr := New Integer[CSource.Dimensions.Count];
    For i := 0 To CSource.Dimensions.Count - 1 Do
        Arr[i] := 0;
    End For;
    //Index of composite dictionary element
    i := CDimInst.ComposeElement(Source, Arr);
    If i <> -1 Then
        Debug.WriteLine(Elements.Name(i));
    End If;
End Sub UserProc;

After executing the example the composite dictionary of a virtual cube is obtained. The development environment console displays the name of data source and elements of fixed source dimensions, that are used to create the name of the specified element of composite dictionary.

See also:

ICompoundDimensionInstance