Create a Category Count Measure and Add to Model Example
This example creates a category count measure and adds it to an existing model.
Sub Example22()
Dim objTransApp As Object
Dim objModel As Object
Dim objMeasure As Object
Dim objLevel As Object
Dim objActMeasure As Object
Dim strIBMCognos10Location As String
Dim strModelPath As String
Dim strModelSource As String
'Change these paths to match your installation
strIBMCognos10Location = "C:\Program Files\IBM\Cognos\c10\"
strModelSource = "great outdoors sales.mdl"
strModelPath = strIBMCognos10Location & _
"webcontent\samples\models\Transformer8\EN\" & strModelSource
objTransApp = CreateObject("IBMCognosTransformer.ApplicationCtrl.1")
With objTransApp
.DataSourcePath = strIBMCognos10Location & "bin"
.TransdaPath = strIBMCognos10Location & "CS7Gateways\bin\TransDa.exe"
End With
objModel = objTransApp.OpenModel(strModelPath)
objMeasure = objModel.Measures.Add()
objLevel = objModel.Dimensions("Sales region").DrillDowns(1).Levels("Branch")
With objLevel
.Unique = True
.Update()
End With
objActMeasure = objModel.Measures("Quantity")
objMeasure.ActivityMeasure = objActMeasure
objMeasure.CategoryCountLevel = objLevel
With objMeasure
.AllowCurrencyConversion = False
.AllowDrillThrough = False
.Name = "Sales branch count"
.OutputScale = 0
.Precision = 0
.ReverseSign = False
.StorageType = xtrStorage.trStorageDefault
.Update()
End With
objModel.SaveAs("great outdoors salesX.mdl")
objModel.Close()
objActMeasure = Nothing
objLevel = Nothing
objMeasure = Nothing
objModel = Nothing
objTransApp = Nothing
End Sub