IEaxDataAreaHierarchies.PushChangesToDimInstance

Syntax

PushChangesToDimInstance(S: IDimSelection; CD: ICustomDimension);

Parameters

S. Dimension where alternative hierarchy is placed.

CD. Facts dimension.

Description

The PushChangesToDimInstance method applies changes accumulated in the facts dimension to the dimension with alternative hierarchy.

Comments

To add element from original hierarchy to facts dimension, use IEaxDataAreaHierarchies.AddExistingElement.

Example

Executing the example requires that the repository contains an express report with the EXPRESS identifier containing table. Table dimensions must contain territory dimension and facts dimension.

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

Sub UserProc;
Var
    MB: IMetabase;
    Express: IEaxAnalyzer;
    Slice: IEaxDataAreaSlice;
    Sel: IDimSelection;
    Hiers: IEaxDataAreaHierarchies;
    HierKey, Elm, i: Integer;
    Hier: IEaxDataAreaHierarchy;
    CustDim: ICustomDimension;
    Ins: IDimInstance;
    Elms: IDimElements;
    ElmName: String;
Begin
    // Get repository
    MB := MetabaseClass.Active;
    // Get express report
    Express := MB.ItemById("EXPRESS").Edit As IEaxAnalyzer;
    // Get hierarchy collection
    Hiers := Express.DataArea.Hierarchies;
    // Check for automatic sorting
    If Not Hiers.IsAutoSort Then
        Hiers.IsAutoSort := True;
    End If;
    // Get data slice
    Slice := Express.DataArea.Slices.Item(0);
    // Get selection of territory dimension
    Sel := Express.Pivot.Selection.Item(3);
    // Add alternative hierarchy to dimension
    HierKey := Hiers.CreateKey(Slice.Key, Sel.Dimension.Key);
    Hier := Hiers.FindByKey(HierKey);
    If Hier = Null Then
        Hier := Hiers.Add(Slice, Sel, HierKey);
        CustDim := Hier.CustomDimension;
        // Clear facts dimension elements
        CustDim.Elements.Clear;
        // Apply changes from facts dimension to territory dimension
        Hiers.PushChangesToDimInstance(Sel, CustDim);
    Else
        CustDim := Hier.CustomDimension;
    End If;
    // Add selection elements from territory dimension to facts dimension
    Ins := Sel.Dimension;
    Elms := Ins.Elements;
    For i := 0 To Sel.SelectedCount - 1 Do
        Elm := Sel.Element(i);
        If Elm <> -1 Then
            ElmName := Elms.Name(Elm);
            Debug.WriteLine("Element name in selection - " + ElmName);
            Hiers.AddExistingElement(Ins, CustDim, Elm, ElmName);
        End If;
    End For;
    // Apply changes from facts dimension to territory dimension
    Hiers.PushChangesToDimInstance(Sel, CustDim);
    // Refresh and save changes
    Express.Pivot.Refresh;
    (Express As IMetabaseObject).Save;
End Sub UserProc;

After executing the example all changes from facts dimension will be applied to territory dimension: existing elements from facts dimension will be added to the territory dimension selection.

See also:

IEaxDataAreaHierarchies