Express > Express Assembly Interfaces > IEaxDataAreaHierarchies > IEaxDataAreaHierarchies.PushChangesToDimInstance
PushChangesToDimInstance(S: IDimSelection; CD: ICustomDimension);
S. The dimension that contains an alternative hierarchy.
CD. Facts dimension.
The PushChangesToDimInstance method applies changes accumulated in the facts dimension to the dimension with alternative hierarchy.
To add an element from original hierarchy to fact dimension, use IEaxDataAreaHierarchies.AddExistingElement.
Executing the example requires that the repository contains an express report with the EXPRESS identifier containing a 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 collection of hierarchies
Hiers := Express.DataArea.Hierarchies;
// Check automatic sorting
If Not Hiers.IsAutoSort Then
Hiers.IsAutoSort := True;
End If;
// Get data slice
Slice := Express.DataArea.Slices.Item(0);
// Get territory dimension selection
Sel := Express.Pivot.Selection.Item(3);
// Add an 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 fact dimension elements
CustDim.Elements.Clear;
// Apply changes from fact dimension to territory dimension
Hiers.PushChangesToDimInstance(Sel, CustDim);
Else
CustDim := Hier.CustomDimension;
End If;
// Add selection elements from territory dimension to fact 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 fact 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 are applied to territory dimension: existing elements from facts dimension are added to the territory dimension selection.
See also: