Selection: IDimSelectionSet;
The Selection property determines selection of dictionary collection for matrix query.
Executing the example requires a cube with the CUBE identifier.
Add links to the Cubes, Dimensions, Matrix, Metabase system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
CubeDest: ICubeInstanceDestination;
Executor: ICubeInstanceDestinationExecutor;
Sels, FilterSel, ResSels: IDimSelectionSet;
Sel: IDimSelection;
Factory: IMatrixFactory;
Matrix: IMatrix;
Query: IMatrixQuery;
Filter: IMatrixQueryFilter;
Values: IArrayList;
Result: IMatrixQueryResult;
Begin
Mb := MetabaseClass.Active;
// Open cube
CubeDest := (Mb.ItemById("CUBE").Open(Null) As ICubeInstance).Destinations.DefaultDestination;
Executor := CubeDest.CreateExecutor;
// Create selection
Sels := CubeDest.CreateDimSelectionSet;
For Each Sel In Sels Do
Sel.SelectAll;
End For;
// Get matrix with cube data
Executor.PrepareExecute(Sels);
Executor.PerformExecuteO(CubeInstanceDestinationExecutorOptions.Cached);
Matrix := Executor.Matrix;
// Create a query
Factory := New MatrixFactory.Create As IMatrixFactory;
Query := Factory.CreateQuery(Matrix);
Filter := Query.Filter;
// Add values for data filtering
FilterSel := CubeDest.CreateDimSelectionSet;
FilterSel.Item(0).SelectElement(0, False);
FilterSel.Item(1).SelectElement(0, False);
// Selection for filtering
Filter.Selection := FilterSel;
// Execute query
Query.Execute;
Result := Query.Result;
Debug.WriteLine("Minimum value in filtered matrix: " + Result.MinValue.ToString);
Debug.WriteLine("Maximum value in filtered matrix: " + Result.MaxValue.ToString);
// Output selection obtained by changing source selection so that
// the matrix contains only data from filter
ResSels := CubeDest.CreateDimSelectionSet;
Result.GetSelectionSet(ResSels);
For Each Sel In ResSels Do
Debug.WriteLine("Dimension: " + (Sel.Dimension.Dimension As IMetabaseObject).Id + ". Selected elements: " + Sel.SelectedCount.ToString + " of " + Sel.Dimension.Elements.Count.ToString);
End For;
End Sub UserProc;
After executing the example the cube opens and its matrix with data by full selection is obtained. A query will be created that gets information about matrix data, a filter that selects data by the specified selection is determined in the query. After executing the query the selection corresponding to the matrix with filtered data is obtained. Information about the selection is displayed in the development environment console.
See also: