Matrix: IMatrix;
The Matrix property returns the output matrix, by which filtering is executed.
Executing the example requires that the repository contains an express report with the EXPRESS identifier that is based on a cube, and a filter with the FILTER identifier. Filter and cube structure and selection are identical.
Add links to the Cubes, Dimensions, Express, Matrix, Metabase, Pivot system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
MbObj: IMetabaseObject;
ObjParams: IMetabaseObjectParamValues;
ObjParamsEx: IMetabaseObjectParamValuesEx;
Eax: IEaxAnalyzer;
Pvt: IPivot;
Filter: IPivotFilterSettings;
FltrSources: IPivotFilterSources;
FltrSource: IPivotFilterSource;
CubeSelSet: IDimSelectionSet;
Cube: ICubeInstance;
Dest: ICubeInstanceDestination;
Mat, Mat1: IMatrix;
MatIt: IMatrixIterator;
i: Integer;
Begin
// Get repository
Mb := MetabaseClass.Active;
// Get cube used as a filter
MbObj := MB.ItemById("FILTER") As IMetabaseObject;
ObjParams := MbObj.Params.CreateEmptyValues;
ObjParamsEx := ObjParams As IMetabaseObjectParamValuesEx;
ObjParamsEx.StateOptions := 2;
Cube := MbObj.Open(ObjParams) As ICubeInstance;
Dest := Cube.Destinations.Item(0);
// Get cube selection
CubeSelSet := Dest.CreateDimSelectionSet;
// Get express report
Eax := MB.ItemById("EXPRESS").Edit As IEaxAnalyzer;
// Get report data table display options
Pvt := Eax.Pivot;
// Determine filtering parameters
Filter := Pvt.Filter As IPivotFilterSettings;
// Set external filter use
FltrSources := Filter.FilterSources;
CubeSelSet := Pvt.Selection;
Pvt.BeginUpdate;
FltrSources.Clear;
// Enable filter use
FltrSources.Enable := True;
// Add filter
FltrSource := FltrSources.Add;
// Add filtering data source
FltrSource.DataSource := Dest As IMatrixDataSource;
// Get selection, by which filtering is executed
FltrSource.Selection := CubeSelSet;
Pvt.EndUpdate;
// Display report data matrix
Mat := Pvt.Matrix;
Debug.WriteLine("====== Matrix ======");
Debug.WriteLine("Number of values: " + Mat.Count.ToString);
Debug.WriteLine("Number of dimensions: " + Mat.DimensionCount.ToString);
For i := 0 To Mat.DimensionCount - 1 Do
Debug.WriteLine(i.ToString + ") '" + Mat.Dimensions.Item(i).Dimension.Name + "' elements selected " + Mat.Dimensions.Item(i).SelectedCount.ToString);
End For;
MatIt := Mat.CreateIterator;
MatIt.Move(IteratorDirection.First);
While MatIt.Valid Do
Debug.WriteLine("(" + MatIt.CoordsAsString + ") " + MatIt.Value);
MatIt.Move(IteratorDirection.Next);
End While;
// Display filter data matrix
Mat1 := FltrSource.Matrix;
Debug.WriteLine("====== Matrix ======");
Debug.WriteLine("Number of values: " + Mat1.Count.ToString);
Debug.WriteLine("Number of dimensions: " + Mat1.DimensionCount.ToString);
For i := 0 To Mat1.Dimensions.Count - 1 Do
Debug.WriteLine(i.ToString + ") '" + Mat1.Dimensions.Item(i).Dimension.Name + "' elements selected " + Mat1.Dimensions.Item(i).SelectedCount.ToString);
End For;
MatIt := Mat1.CreateIterator;
MatIt.Move(IteratorDirection.First);
While matit.Valid Do
Debug.WriteLine("(" + MatIt.CoordsAsString + ") " + MatIt.Value);
MatIt.Move(IteratorDirection.Next);
End While;
// Save report
(Eax As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the console window displays the number of values, the number of dimensions, dimension names, the number of selected elements, data matrices for express report and filter. The report will have only values of the elements, for which there are values in the filter.
See also: