IEaxDataAreaHierarchies.AddEx

Syntax

AddEx(Slice: IEaxDataAreaSlice;

    DS: IDimSelection;

    Key: Integer;

    [ElementsToCopy: IDimSelection = Null];

    [CloneAttributes: Boolean = True]): IEaxDataAreaHierarchy;

Parameters

Slice. Analytical data area slice.

DS. Dimension selection.

Key. Dimension key.

ElementsToCopy. Selection where elements of current selection will be added. Optional parameter, to ignore it, use Null.

CloneAttributes. Indicates whether a link is created between source dictionary attributes and alternative hierarchy attributes. Optional parameter, True is sent by default, and links between attributes are created automatically.

Description

The AddEx method adds new alternative hierarchy to collections with the ability to manage links between source dictionary attributes and alternative dictionary attributes.

Example

Executing the example requires that the repository contains an express report with the EXPRESS identifier containing a table. Express report source has at least three dimensions.

Add links to the Dimensions, Express, Metabase, Pivot system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Report: IEaxAnalyzer;
    Slice: IEaxDataAreaSlice;
    DimSS: IDimSelectionSet;
    Dims: IDimSelection;
    Hiers: IEaxDataAreaHierarchies;
    HKey: Integer;
    Hierarchy: IEaxDataAreaHierarchy;
Begin
    Mb := MetabaseClass.Active;
    Report := Mb.ItemById("EXPRESS").Bind As IEaxAnalyzer;
    Slice := Report.Grid.Slice;
    Hiers := Report.DataArea.Hierarchies;
    DimSS := Report.Pivot.Selection;
    // ---Create an alternative hierarchy without attribute binding---
    Dims := DimSS.Item(1);
    HKey := Hiers.CreateKey(Slice.Key, Dims.Dimension.Key);
    Debug.WriteLine(HKey);
    Hierarchy := Hiers.FindByKey(HKey);
    If Hierarchy = Null Then
        Hierarchy := Hiers.AddEx(Slice, Dims, HKey, NullFalse);
    End If;
    Hiers.PushChangesToDimInstance(Dims, Hierarchy.CustomDimension);
    // View information about attribute binding
    ShowAttributeInfo(Hierarchy, "---Without attribute binding---");
    // ---Create an alternative hierarchy with attribute binding---
    Dims := DimSS.Item(2);
    HKey := Hiers.CreateKey(Slice.Key, Dims.Dimension.Key);
    Debug.WriteLine(HKey);
    Hierarchy := Hiers.FindByKey(HKey);
    If Hierarchy = Null Then
        Hierarchy := Hiers.AddEx(Slice, Dims, HKey, NullTrue);
    End If;
    Hiers.PushChangesToDimInstance(Dims, Hierarchy.CustomDimension);
    ShowAttributeInfo(Hierarchy, "---With attribute binding---");
End Sub UserProc;
Sub ShowAttributeInfo(Hierarchy: IEaxDataAreaHierarchy; Info: String);
Var
    DimHierarhy: IDimHierarchy;
    Attr: IDimAttribute;
Begin
    Debug.WriteLine(Info);
    DimHierarhy := Hierarchy.Hierarchy.Hierarchy;
    // View information about attribute binding
    For Each Attr In DimHierarhy.Original.Attributes Do
        If (DimHierarhy.SourceAttribute(Attr) <> NullThen
            Debug.WriteLine("Link between attributes: " + Attr.Id + " : " + DimHierarhy.SourceAttribute(Attr).Id);
        End If;
    End For;
End Sub ShowAttributeInfo;

After executing the example, two hierarchies by two different dimensions are added to the list of alternative hierarchies of analytical data area. The first hierarchy will not have bound attributes of source and alternative dictionaries, on which the dimension is based. Only the attributes with the Key and Name purpose will be bound, which are necessary for hierarchy work. Links between all attributes will be set up for the second hierarchy. Information about attribute bindings will be displayed in the development environment console.

See also:

IEaxDataAreaHierarchies