AggregateDimSelection(DimKey: Integer): Boolean;
DimKey. Data source dimension key.
The AggregateDimSelection property determines whether a dimension is excluded from a cube on aggregation of fixed dimension data.
It is used if data aggregation is enabled by all cube dimension elements:
The Aggregate Data by Dimensions with Full Selection checkbox is selected in the standard cube wizard.
The IStandardCubeDestination.SelSetOriginalOnly property is set to True.
To aggregate data by single cube dimension elements:
Set the AggregateDimSelection property to True.
Specify partial selection of dimension elements, which is used in aggregation, by means of the ICubeInstanceDestination.CreateDimSelectionSet method.
Available values:
True. Data is aggregated by a dimension with partial selection.
False. Default value. Data is aggregated by a dimension with full selection.
Executing the example requires that the repository contains a standard cube with the CUBE identifier. The cube should contain a dimension with the DIMENSION identifier, and data aggregation is set up.
Add links to the Cubes, Dimensions, Matrix, Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Cube: IStandardCube;
CubeDest: IStandardCubeDestination;
CubeIns: ICubeInstance;
DictInst: IDimInstance;
Dest: ICubeInstanceDestination;
MatrDS: IMatrixDataSource;
MatrExecutor: IMatrixDataSourceExecutor;
Executor: ICubeInstanceDestinationExecutor;
SelSet: IDimSelectionSet;
Sel: IDimSelection;
Mat: IMatrix;
Ite: IMatrixIterator;
Line: String;
Begin
// Get the current repository
MB := MetabaseClass.Active;
// Get standard cube
Cube := MB.ItemById("CUBE").Edit As IStandardCube;
// Get the first cube display version on aggregation
CubeDest := Cube.Destinations.Item(0);
// Check if data aggregation is executed by dimension with full selection
If CubeDest.SelSetOriginalOnly Then
Debug.WriteLine("Aggregation is used");
Else
// Enable aggregation if it is disabled
CubeDest.SelSetOriginalOnly := True;
// Save changes in cube
(Cube As IMetabaseObject).Save;
End If;
// Get cube instance
CubeIns := MB.ItemById("CUBE").Open(Null) As ICubeInstance;
// Get dimension
DictInst := MB.ItemById("DIMENSION").Open(Null) As IDimInstance;
Dest := CubeIns.Destinations.DefaultDestination;
// Create an object for cube calculation
MatrDS := Dest As IMatrixDataSource;
MatrExecutor := MatrDS.CreateExecutor;
Executor := MatrExecutor As ICubeInstanceDestinationExecutor;
// Exclude the obtained change from cube on aggregation execution
Executor.AggregateDimSelection(DictInst.Key) := True;
// Create an empty cube selection
SelSet := Dest.CreateDimSelectionSet;
// Select all dimension elements, but the obtained dimension, deselect the first element in this dimension
For Each Sel In SelSet Do
If Sel.Dimension = DictInst Then
Sel.SelectAll;
Sel.DeselectElement(0, False);
Else
Sel.SelectAll;
End If;
End For;
// Calculate data matrix according to the selection
Mat := MatrExecutor.Execute(SelSet);
Ite := Mat.CreateIterator;
Ite.Move(IteratorDirection.First);
While Ite.Valid Do
// Display selection result in the console, by which aggregation will be executed
Line := Ite.CoordsAsString + " " + Ite.Value;
Debug.WriteLine(Line);
Ite.Move(IteratorDirection.Next);
End While;
End Sub UserProc;
After executing the example, partial selection of the dimension with the DIMENSION identifier is used for data aggregation, the rest of the dimensions are used with full selection. The console will display information about use of data aggregation and corresponding dimension element selection.
See also: