Professional > Data management scripting > Publishing data > Cognos Framework Manager models > Building simple reports in Cognos Report Studio > Creating reports for grid questions > Adding a Mean column
 
Adding a Mean column
The following example follows the same basic steps as outlined in Building simple reports in Cognos Report Studio.
1 Create a basic report as detailed in Building simple reports in Cognos Report Studio.
2 Select the Tool box tab in the Insertable Objects pane and in the Query Explorer pane, add a new Query Calculation object named FactoredColumn.
3 Enter the following Expression Definition value in the Data Item Expression dialog:
case
when [rating].[Dimensions].[Column]='Not at all interested (1)' then 1
when [rating].[Dimensions].[Column]='Not particularly interested (2)' then 2
when [rating].[Dimensions].[Column]='No opinion (3)' then 3
when [rating].[Dimensions].[Column]='Slightly interested (4)' then 4
when [rating].[Dimensions].[Column]='Very interested (5)' then 5
else null
End
4 In Page Explorer, select the Tool box tab in the Insertable Objects pane and in the Query Explorer pane, add a new Query Calculation object named Mean.
5 Enter the following Expression Definition value in the Data Item Expression dialog:
average([FactoredColumn])
Report specification
Serial
<#Column#>
<Mean>
 
 
<#LevelID#>
<#1234#>
<#1234#>
<#LevelID#>
<#1234#>
<#1234#>
Result
The report is rendered as:
Serial
Not at all interested (1)
Not particularly interested (2)
No opinion (3)
Slightly interested (4)
Very interested (5)
NA (Auto Created)
Mean
Dinosaurs
10
1
27
113
107
40
4.186
Conservation
3
2
7
30
14
242
3.893
Fish and reptiles
6
5
28
45
27
187
3.739
Fossils
6
1
15
25
18
233
3.738
Birds
9
8
18
32
27
204
3.638
Insects
13
2
18
27
19
219
3.468
Whales
2
 
14
28
38
216
4.220
Mammals
4
3
26
55
50
160
4.043
Minerals
13
6
14
25
28
212
3.570
Ecology
3
 
5
10
10
270
3.857
Botany
11
3
13
14
14
243
3.309
Origin of species
4
4
16
29
49
196
4.127
Human biology
4
5
17
34
63
175
4.195
Evolution
12
2
18
41
44
181
3.880
Wildlife in danger
 
1
2
16
13
266
4.281
Other
 
 
 
 
 
298
 
See also
Building simple reports in Cognos Report Studio