Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Addlevel for categories in PowerPlay

Status
Not open for further replies.

trevwoody

Programmer
Feb 6, 2003
24
GB
Hello all.
Does anyone have a macro for PP that adds child categories to their parents in a nested crosstab? I am trying to get this going but am only achieving all children to all parents or all children to a single parent category.
My alternative is to loop through each parent and then add their children but this will be very processor intensive.

Thanks in advance for any help or suggestions.

Trevor
 
Resolved. For future reference, should anyone need the solution, the macro follows.
It uses 2 reports - the final one and a 'working report' to hold the list of parent categories. This is cycled through to move the cursor on the final report. It is also used to add the child categories to the category list object, which are then placed under the active row on the main report.
I have not bothered to put in the quit and save for the associated reports.

Sub Main()
Dim objCubeCategories As Object
Dim Morcats as Object
Dim objDimensionLine as Object
Dim cat1 as Object
Dim objPPRep As Object
Dim PPRep2 as Object
Dim ObjCubeCat1 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
Dim Rowcount as Integer

Set objPPRep = CreateObject("CognosPowerPlay.Report")
objPPRep.New "C:\Program Files\Cognos\cer2\Samples\PowerPlay\Cubes and Reports\Great Outdoors.mdc", -1
objPPRep.ExplorerMode = False
objPPRep.Visible = True
Set PPRep2 = CreateObject("CognosPowerPlay.Report")
PPRep2.New "C:\Program Files\Cognos\cer2\Samples\PowerPlay\Cubes and Reports\Great Outdoors.mdc", -1
PPRep2.ExplorerMode = False
PPRep2.Visible = True
PPRep2.Rows.Select
PPRep2.DeleteSelected
PPRep2.Columns.Select
PPRep2.DeleteSelected
Set morcats = PPRep2.CategoryList()
Morcats.Add 1,"Years"
PPRep2.Rows.Add morcats

Set objCubeCategories = objPPRep.CategoryList()
Set Morcats = objPPRep.CategoryList()
PPRep2.Rows.Add Morcats

Rowcount = PPRep2.Rows.Count()
for t = 1 to rowcount
rowname = PPRep2.Rows.Item(t).Name
objPPRep.Rows.Item(rowname).Activate
objCubeCategories.Add 2,"Years",PPRep2.Rows.Item(t).Name
objPPRep.Rows.AddLevel objCubeCategories , 0, 0, 1
objcubecategories.Remove
next t

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top