Average Method (Collections) (Reporter)

Returns the average of a constant value or a category, and either one or more categories.

Syntax

collection.Average [Operand]

Applies To

Columns

Layers

Rows

Discussion

This method is only available if the Report object is in Reporter mode (ExplorerMode property set to False).

Depending on whether the method was applied to an object or a collection, the results are returned respectively as an object or a collection. The new calculation is inserted directly after the active row or column.

References to the position of an object in the collection are not valid after you use this method.

Parameters

Description

Operand

Required. Specifies either a constant value or a category object.

Type: Variant

Return Type

Object

Example

This example determines the average of the first three rows and the average of column one and four in a Reporter report.

Sub Main()
   Dim objPPRep As Object
   Dim objNewCol As Object
   Dim objNewRow As Object
   Set objPPRep = GetObject( , "CognosPowerPlay.Report")
   objPPRep.ExplorerMode = False
   Set objNewRow = objPPRep.Rows.Subset(1, 3).Average
   MsgBox "The average of the first three rows is " _
      &objPPRep.CellValue(objNewRow(1).Index,1)
   Set objNewCol = objPPRep.Columns.Item(4).Average _
      (objPPRep.Columns.Item(1))
   MsgBox " The average of column one and column four
is " _
      &objPPRep.CellValue(1,objNewCol.Index)
   objPPRep.Save
   Set objNewRow = Nothing
   Set objNewCol = Nothing
   Set objPPRep = Nothing
End Sub

Related Topics