Values: IArrayList;
The Values property returns a dynamic array of filter elements.
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, 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
Values := Filter.Values;
Values.Add(1);
Values.Add(3);
Values.Add(5);
// Selection for filtering
Filter.Selection := Sels;
// 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 is created that gets information about matrix data, a filter that selects data with definite values is determined in the filter. 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: