When working with the express report, which is built on several sources, shared dimensions for all sources are displayed as separate dimensions. The dimensions that are unique for the sources are united into a separate dimensions and are displayed on the Private Dimensions tab. Sometimes it may require to move one of shared dimensions to Private Dimensions. Consider the example of such moving by means of the Fore language.
Executing the example requires a form with the Button1 button, the TabSheetBox, ErAnalyzerDimPanel, and the UiErAnalyzer component named UiErAnalyzer1 that is a data source for the mentioned visual components. An express report built on several data sources is connected to UiErAnalyzer1. Shared dimensions contain a dimension with the Country identifier.
Apart from the assemblies that will be connected automatically, it is also required to add links to the Cubes, Dimensions, Express, Metabase, Pivot repository system assemblies.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Analyzer: IEaxAnalyzer;
Pivot: IPivot;
Selection, NewSel: IDimSelection;
DataSources: IEaxDataSources;
FixInfo: ICubeDimensionFixInfo;
VirtualCube: IVirtualCube;
CompoundSelection: ICompoundSelection;
SourcesSelection: IDimSelectionSet;
SourceSelection: ICompoundSelection;
DimFix: ICubeDimensionFix;
DimKey, CompoundDimKey, i: Integer;
Begin
Analyzer := UiErAnalyzer1.ErAnalyzer;
Pivot := Analyzer.Pivot;
//Selection of the dimension, which will be moved to private
//This dimension is contained in all express report data sources
//Selection is required for its further restoring in composite selection of private dimension
Selection := Pivot.Selection.FindById("COUNTRY");
//Key of moved dimension
DimKey := Selection.Dimension.Key;
//Fixation of the dimension in virtual cube, which is created below express report
DataSources := Analyzer.DataSources;
For i := 0 To DataSources.Count - 1 Do
FixInfo := DataSources.Item(i).VirtualCubeSource.FixInfo;
DimFix := FixInfo.FindByKey(DimKey);
DimFix.Fixed := True;
End For;
//Get composite selection, which includes all selections of private dimensions
VirtualCube := (Pivot.DataSource As ICubeInstanceDestination).Cube.Cube As IVirtualCube;
CompoundDimKey := (VirtualCube.FactDimension As IMetabaseObjectDescriptor).Key;
CompoundSelection := Pivot.Selection.FindByKey(CompoundDimKey) As ICompoundSelection;
//Collection of selections of private dimensions
//Each selection of private dimension in its turn is also composite selection of the dimensions, which are unique for
//specific data source
SourcesSelection := CompoundSelection.Selection;
Pivot.BeginSelectionUpdate;
For Each SourceSelection In SourcesSelection Do
//Add a moved dimension selection to private dimension selection
NewSel := SourceSelection.Selection.Add(Selection.Dimension);
//Restore dimension selection according to the selection, which was before moving
Selection.CopyTo(NewSel, True);
End For;
Pivot.EndSelectionUpdate;
//Refresh data sources
DataSources.Refresh;
End Sub Button1OnClick;
The list of dimensions looks as follows:
After clicking the button the list of dimensions looks as follows:
See also: