ICubeExecuteDataTypes.AddCoord

Syntax

AddCoord(Coord: IMatrixCoord; Type: CubeDataType);

AddCoord(Coord: Prognoz.Platform.Interop.Matrix.IMatrixCoord; Type: Prognoz.Platform.Interop.Cubes.CubeDataType);

Parameters

Coord. Coordinate of the cell with data.

Type. The method of data creation that is to be set for the cell.

Description

The AddCoord method sets how data is generated for the cell with the specified coordinate.

Example

Executing the example requires a standard cube with the STD_CUBE identifier. The cube contains two dimensions and facts dimension. Aggregation is set by any dimension.

Add links to the Cubes, Dimensions, Matrix and Metabase system assemblies. In Fore.NET add a link to the ForeSystem assembly.

Sub UserProc;
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    Dest: ICubeInstanceDestination;
    Sels: IDimSelectionSet;
    Sel: IDimSelection;
    Exec: ICubeInstanceDestinationExecutor;
    Matr: IMatrix;
    CubeExecRes: ICubeExecuteResult;
    CubeDataTyp: ICubeExecuteDataTypes;
    Coord: IMatrixCoord;
Begin
    
// Open cube
    MB := MetabaseClass.Active;
    CubeInst := MB.ItemById(
"STD_CUBE").Open(NullAs ICubeInstance;
    Dest := CubeInst.Destinations.DefaultDestination;
    
// Set selection
    Sels := Dest.CreateDimSelectionSet;
    
For Each Sel In Sels Do
        Sel.SelectAll;
    
End For;
    
// Set support of working with information about how data is generated in the cells
    (Sels As ICubeExecuteSetup).UseDataTypes := True;
    Exec := Dest.CreateExecutor;
    
// Calculate cube
    Exec.PrepareExecute(Sels);
    Exec.PerformExecuteO(CubeInstanceDestinationExecutorOptions.None);
    Matr := Exec.Matrix;
    ShowMatrix(
"Cube matrix", Matr);
    
// Set how data is generated for a cell
    CubeExecRes := Matr As ICubeExecuteResult;
    CubeDataTyp := CubeExecRes.DataTypes;
    Coord := Matr.CreateCoord;
    Coord.Item(
0) := 0;
    Coord.Item(
1) := 0;
    Coord.Item(
2) := 0;
    CubeDataTyp.AddCoord(Coord, CubeDataType.Calculated);
    ShowMatrix(
"Matrix after creating the way how data is generated for the cell", Matr);
End Sub UserProc;

Sub ShowMatrix(Title: String; Matr: IMatrix);
Var
    Iter: IMatrixIterator;
    CubeExecRes: ICubeExecuteResult;
    CubeDataTyp: ICubeExecuteDataTypes;
    S: String;
    Coord: IMatrixCoord;
Begin
    CubeExecRes := Matr 
As ICubeExecuteResult;
    CubeDataTyp := CubeExecRes.DataTypes;
    Iter := Matr.CreateIterator;
    Iter.Move(IteratorDirection.First);
    Debug.WriteLine(Title);
    Coord := Matr.CreateCoord;
    
While Iter.Valid Do
        S := (Iter.Value 
As String) + "   (" + Iter.CoordsAsString + ")";
        Iter.PutCurrentPos(Coord);
        
If CubeDataTyp.DataType(Coord) <> CubeDataType.Default_ Then
            S := S + 
"*";
        
End If;
        Debug.WriteLine(s);
        Iter.Value := (Iter.Value 
As Integer) + 1;
        Iter.Move(IteratorDirection.Next);
    
End While;
End Sub ShowMatrix;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    Dest: ICubeInstanceDestination;
    Sels: IDimSelectionSet;
    Sel: IDimSelection;
    Exec: ICubeInstanceDestinationExecutor;
    Matr: IMatrix;
    CubeExecRes: ICubeExecuteResult;
    CubeDataTyp: ICubeExecuteDataTypes;
    Coord: IMatrixCoord;
Begin
    
// Open cube
    MB := Params.Metabase;
    CubeInst := MB.ItemById[
"STD_CUBE"].Open(NullAs ICubeInstance;
    Dest := CubeInst.Destinations.DefaultDestination;
    
// Set selection
    Sels := Dest.CreateDimSelectionSet();
    
For Each Sel In Sels Do
        Sel.SelectAll();
    
End For;
    
// Set support of working with information about how data is generated in the cells
    (Sels As ICubeExecuteSetup).UseDataTypes := True;
    Exec := Dest.CreateExecutor();
    
// Calculate cube
    Exec.PrepareExecute(Sels);
    Exec.PerformExecuteO(CubeInstanceDestinationExecutorOptions.cideoNone 
As Integer);
    Matr := Exec.Matrix;
    ShowMatrix(
"Cube matrix", Matr);
    
// Set how data is generated for a cell
    CubeExecRes := Matr As ICubeExecuteResult;
    CubeDataTyp := CubeExecRes.DataTypes;
    Coord := Matr.CreateCoord();
    Coord.Item[
0] := 0;
    Coord.Item[
1] := 0;
    Coord.Item[
2] := 0;
    CubeDataTyp.AddCoord(Coord, CubeDataType.cubdtCalculated);
    ShowMatrix(
"Matrix after creating the way how data is generated for the cell", Matr);
End Sub;

Shared Sub ShowMatrix(Title: String; Matr: IMatrix);
Var
    Iter: IMatrixIterator;
    CubeExecRes: ICubeExecuteResult;
    CubeDataTyp: ICubeExecuteDataTypes;
    S: String;
    Coord: IMatrixCoord;
Begin
    CubeExecRes := Matr 
As ICubeExecuteResult;
    CubeDataTyp := CubeExecRes.DataTypes;
    Iter := Matr.CreateIterator();
    Iter.Move(IteratorDirection.itdFirst);
    System.Diagnostics.Debug.WriteLine(Title);
    Coord := Matr.CreateCoord();
    
While Iter.Valid Do
        S := (Iter.Value 
As String) + "   (" + Iter.CoordsAsString + ")";
        Iter.PutCurrentPos(Coord);
        
If CubeDataTyp.DataType[Coord] <> CubeDataType.cubdtDefault Then
            S := S + 
"*";
        
End If;
        System.Diagnostics.Debug.WriteLine(s);
        Iter.Move(IteratorDirection.itdNext);
    
End While;
End Sub;

On executing the example the cube output matrix is calculated. The development environment console displays information about matrix: values in cells and cells coordinates. The cells containing calculated data will be marked by the * character. After that for the first cell the way how data is generated will be set and information about matrix will be repeatedly displayed at the development environment console.

See also:

ICubeExecuteDataTypes