Exploring OLAP Cube with Visual Basic - Properties of the Cube: Properties of Dimensions
(Page 4 of 6 )
A cube is constructed from dimensions and measures, as mentioned earlier. Cubes store data derived from relational data and contain categorized data useful in analysis. These categories are the dimensions, and should be distinct. If the data type in the dimension is of type time, it is called a Time dimension; otherwise, it is a Standard dimension.
The following code will bring out all the properties of the dimensions. Notice that the connection is of the type ADODB. The connection string is simple, containing the provider, the SQL Server data, and the Initial Catalog. The ocube is the cube object described in the catalog. This code counts the number of dimensions (4); lists the various dimensions (Measures, MyOrders, MyProducts, MyCustomers, MyOrders); and lists the various properties (17) of the Measures.
Private Sub Command1_Click()
'Open a connection by providing a
'connection string
oCn.Open "Provider=MSOLAP;Data Source=NECHOST; & _
Initial Catalog=NewOlap;"
'Catalog's active connection is established
Set oCat.ActiveConnection = oCn
'Cube is defined by catalog's CubeDef()method
Set ocube = oCat.CubeDefs(0)
'Cube's dimension is defined
Set ocdim = oCat.CubeDefs(0).Dimensions(0)
'number of dimensions in the cube counted
Debug.Print ocube.Dimensions.Count
Dim ccnt As Integer
ccnt = ocube.Dimensions.Count
Dim j
For j = 0 To ccnt - 1
Debug.Print "------"
'name of dimension printed
Debug.Print ocube.Dimensions(j).Name
Next j
'dimensions properties are counted
Debug.Print ocdim.Properties.Count
Dim cnt
cnt = ocdim.Properties.Count
Dim i
For i = 0 To cnt - 1
'Dimenion's Name, Type, and value are printed
Debug.Print ocdim.Properties(i).Name & "," & _
ocdim.Properties(i).Type & "," & _
ocdim.Properties(i).Value
Next
End Sub
The above code accesses the properties of the shared dimensions of the cube, as shown in this picture.
The result of running the above procedure produces the following the properties of the Measures. A similar result is obtained for the other dimensions as well.
4
------
Measures same as, MyOrderDetails in the above picture
------
MyCustomers
------
MyOrders
------
MyProducts
17
CATALOG_NAME,202,NewOlap
SCHEMA_NAME,202,
CUBE_NAME,202,MyFirstCube
DIMENSION_NAME,202,Measures
DIMENSION_UNIQUE_NAME,202,[Measures]
DIMENSION_GUID,72,
DIMENSION_CAPTION,202,Measures
DIMENSION_ORDINAL,19,0
DIMENSION_TYPE,2,2
DIMENSION_CARDINALITY,19,3
DEFAULT_HIERARCHY,202,[Measures]
DESCRIPTION,202,
IS_VIRTUAL,11,False
IS_READWRITE,11,False
DIMENSION_UNIQUE_SETTINGS,3,0
DIMENSION_MASTER_UNIQUE_NAME,202,
DIMENSION_IS_VISIBLE,11,True
Next: Properties of Hierarchies >>
More Database Articles
More By Jayaram Krishnaswamy