AddLevel Method

Adds a row, column, or layer level to a nested crosstab.

Syntax

collection.Addlevel CubeCategories, Level, Action, Position

Applies To

Columns

Layers

Rows

Discussion

Use this method to insert a collection of Category objects into a nested crosstab at the current position of the cursor at the specified level. The new level contains the categories in the category list.

The level can be inserted at a nesting level or group level (child categories for a parent category), depending on the setting of the Action parameter. Adding a group level adds the categories to all the categories at the given level that are part of the same group. The level can be either a parent or a child, depending on the setting of the Position parameter.

The level is set using the Level parameter, where 0 indicates the level closest to the actual data (that is, the lowest level row or column), 1 indicates the next level up, and so on. For example, where a financial crosstab has levels for Years and Months and then data, level 0 is Months and level 1 is Years.

AddLevel applies only to nested crosstabs. If the graph displayed is not a nested crosstab, the method generates an error.

In Explorer mode, when you add a level from the same dimension, the Action parameter is ignored.

Parameter

Description

CubeCategories

Required. Specifies a collection of Category objects to be added to the given Dimension (rows, columns, or layers) and the specified level.

Type: Object

Level

Required. Specifies the nesting level in which to add the categories.

Type: Long

Action

Required. Specifies where to add the level:

1 = add at the group level. 0 = add at the nesting level

Note: Set this parameter to 1 (group) when the Position parameter is set to False (parent).

Type: Integer

Position

Required. Specifies whether the category is added as a parent or child.

False = parent level True = child level

Type: Boolean

Return Type

Object

Example

This example adds a new nesting level of categories, as rows, to a report and then adds a new nesting level of columns.

Sub Main()
   Dim objCubeCategories As Object
   Dim objPPRep As Object
   Const level_0 = 0
   Const level_1 = 1
   Const add_to_current = 0
   Const add_to_all = 1
   Const as_parent = 0
   Const as_child = 1
   Set objPPRep = CreateObject("CognosPowerPlay.Report")
   objPPRep.New "C:\Cubes and Reports\Great Outdoors.mdc",
-1
   objPPRep.ExplorerMode = False
   objPPRep.Visible = True
   Set objCubeCategories = objPPRep.CategoryList()
   objCubeCategories.Add level_1, "Channels" 
   objPPRep.Rows.AddLevel objCubeCategories, level_0,
_
         add_to_all, as_child
   objCubeCategories.Remove
   objCubeCategories.Add level_1, "Locations" 
   objPPRep.Columns.AddLevel objCubeCategories, level_0,
_
         add_to_all, as_child
   Set objCubeCategories = Nothing
   Set objPPRep = Nothing
End Sub

Related Topics