An object of ClassType clsCubeLevel provides a specific implementation of the Decision Support Objects (DSO) Level interface. This object provides collections and properties through the Level interface. There are no methods associated with an object of ClassType clsCubeLevel.
When a dimension within a database is assigned to a cube, the cube inherits all levels of the dimension. An object of ClassType clsCubeLevel allows access to these levels. One advantage of accessing a cube's levels is to avoid traversing the dimensions and levels in the database (not all database dimensions necessarily apply to a given cube) to determine which levels are used in aggregations for a cube's partition. Also, some properties such as IsDisabled may only be set for a cube level object.
For more information, see Level Interface and About Decision Support Objects.
Use the following code to create dimension and levels for a database and apply them to a cube.
'Assume an object (dsoDB) of ClassType clsDatabase exists
'with an existing datasource
Dim dsoDim As DSO.Dimension
Dim dsoLevel As DSO.Level
Dim dsoDS As DSO.Datasource
'Add a dimension and levels to the database
Set dsoDS = dsoDB.Datasources(1)
Set dsoDim = dsoDB.Dimensions.AddNew("Products")
Set dsoDim.DataSource = dsoDS 'Dimension DataSource
dsoDim.FromClause = "product" 'Source Table
'Product Brand Level
Set dsoLev = dsoDim.Levels.AddNew("Brand Name")
dsoLev.MemberKeyColumn = """product"".""brand_name"""
dsoLev.ColumnSize = 255
dsoLev.ColumnType = adWChar
dsoLev.EstimatedSize = 100
'Product Name Level
Set dsoLev = dsoDim.Levels.AddNew("Product Name")
dsoLev.MemberKeyColumn = """product"".""product_name"""
dsoLev.ColumnSize = 255
dsoLev.ColumnType = adWChar
dsoLev.EstimatedSize = 1560
dsoDim.Update
'Add additional dimensions and levels as required
...
'Add cube to database
Dim dsoCube As MDStore
Set dsoCube = dsoDB.MDStores.AddNew(strCubeName)
'Set the cube's DataSource
Set dsoDS = dsoDB.DataSources(1)
dsoCube.DataSources.AddNew (dsoDS.Name)
'Set source Fact Table and Estimated Rows in Fact Table
dsoCube.SourceTable = """sales_fact_1998"""
dsoCube.EstimatedRows = 1000
'Add shared database dimensions
'Cube inherits dimension levels
dsoCube.Dimensions.AddNew ("Products")
'Add other shared or private dimensions