COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cham on 14 Sep 2011 04:11:26 PM

Title: YTD calculation depending on the metrics
Post by: cham on 14 Sep 2011 04:11:26 PM
Hi Gurus,

I need some help for YTD calculation(Total or Average) depending on the metrics. But it should show under one column(YTD) in the crosstab.

Suppose my crosstab looks like :

               Jan 2011   Feb 2011  Mar 2011  YTD

Metric A      1                 1            1               3  (total)             
Metric B      2                 2            2               2  (average)
Metric C      3                 1            2               6  (total)     

.
.
Metric N     3                  5            1               3(average)

So, under YTD column it should show either TOTAL or AVERAGE(for time) depending on the metrics. For few metrics it should be total and for few of them it should be Average.

So, My question is how to show total or average calculation under the same column(YTD) in the crosstab.

Please help me in this regard.

thank you.
Title: Re: YTD calculation depending on the metrics
Post by: cham on 15 Sep 2011 08:48:45 AM
Any help on this is appreciated.
Title: Re: YTD calculation depending on the metrics
Post by: CognosPaul on 15 Sep 2011 02:07:19 PM
Is this relational or dimensional?
Title: Re: YTD calculation depending on the metrics
Post by: PRIT AMRIT on 16 Sep 2011 01:24:28 AM
Have you tried to manipulate the cognos generated YTD total column? How about writing a case or if/else statement within it?

case
when [Metric] ='Metric A ' then Total([Measure])
when [Metric] ='Metric B ' then average([Measure])
----
-----
end

Does it helps?
Title: Re: YTD calculation depending on the metrics
Post by: cham on 16 Sep 2011 12:10:14 PM
This is dimensional(DMR).
Title: Re: YTD calculation depending on the metrics
Post by: cham on 16 Sep 2011 12:16:00 PM
Hi Prit,

Can you please explain this in detail. I am not getting how to get [Metric] in the above mentioned CASE statement. Please explain it in detail.
Title: Re: YTD calculation depending on the metrics
Post by: CognosPaul on 18 Sep 2011 02:15:43 PM
You can control the aggregation displayed with clever use of style variables. First, what logic do you use to determine which metric displays which form of aggregation?

Let's assume you have an member attribute for it. So drag that attribute to the query, and attach it to the properties of your member node. Create a new string variable called "Agg Type". Values: Total, Avg. The variable expression should be something like:

[Query 1].[Agg Type Attribute] or case when [Query 1].[Agg Type Attribute] = 1 then 'Total' else 'Avg' end

Now the clever bit. Drag in both a total and an avg fields to the crosstab.

So it should look something like:

Corner   | Measure | Total | AVG
---------+---------+-------+-----
Metric A |  123    |  123  |  123
Metric B |  123    |  123  |  123
Metric C |  123    |  123  |  123
Metric D |  123    |  123  |  123


Right click on the Total Node and select member fact cells. Set the style variable to "Agg Type" and check off Avg. When it's AVG then the box type should be none. Use the same idea for the AVG column.

Set the AVG column header to box type none, and rename Total to something more generic.

That should work now.
Title: Re: YTD calculation depending on the metrics
Post by: cham on 19 Sep 2011 12:28:28 PM
Thanks. I will try this.
Title: Re: YTD calculation depending on the metrics
Post by: kalyanapu on 19 Sep 2011 08:04:30 PM
I agree with Paul Suggestion.
It works well.

-
Srinivas Kalyanapu