Count: Integer;
The Count property returns the number of matrix cells with values.
Executing the example requires a cube with the CUBE identifier. The cube contains two dimensions.
Add links to the Cubes, Dimensions, Matrix, Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
CubInst: ICubeInstance;
Des: ICubeInstanceDestination;
Sels: IDimSelectionSet;
Matr: IMatrix;
Coord: IMatrixCoord;
Sto: ICubeInstanceStorage;
Begin
MB := MetabaseClass.Active;
CubInst := MB.ItemById("CUBE").Open(Null) As ICubeInstance;
Des := CubInst.Destinations.DefaultDestination;
// Cube selection
Sels := Des.CreateDimSelectionSet;
Sels.Item(0).SelectAll;
Sels.Item(1).SelectAll;
// Get values matrix by the specified selection
Matr := Des.Execute(Sels);
Debug.WriteLine("Number of cells with values before change: " + Matr.Count.ToString);
Matr.ValueFlag := 1;
// Change values in matrix cells
Coord := Matr.CreateCoord;
Coord.Item(0) := 0;
Coord.Item(1) := 0;
Matr.Item(Coord) := (Matr.Item(Coord) As Double) + 10;
Coord.Item(0) := 0;
Coord.Item(1) := 1;
Matr.Item(Coord) := (Matr.Item(Coord) As Double) + 100;
Coord.Item(0) := 0;
Coord.Item(1) := 2;
Matr.Item(Coord) := (Matr.Item(Coord) As Double) + 1000;
Debug.WriteLine("Number of cells with values after change: " + Matr.Count.ToString);
Debug.WriteLine("Number of cells with checkbox 1: " + Matr.CountV(1).ToString);
// Save changes
Sto := Des.CreateStorage(CubeInstanceStorageOptions.None);
Sto.SaveMatrix(Matr, Matr.ValueFlag);
End Sub UserProc;
After executing the example, a matrix with data will be obtained from the cube. The development environment console displays the number of cells with values. Values will be changed by several coordinates. The development environment console displays again the number of cells with values and also the number of cells selected with the 1 checkbox. After this all changed data will be saved to the cube.
See also: