COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: thedon_1 on 22 Feb 2012 04:33:51 AM

Title: Can't get a simple minus calculation to work
Post by: thedon_1 on 22 Feb 2012 04:33:51 AM
I have 2 joined queries, one that gives me figures for a single period, then a % (lets say M1) of one measure over the other. I have then joined via an outer join to another query which is the same thing but for a group of periods.

In the final query (result of the joins) I have a variance of M1 between the 2 queries. The actual % values from each query are right, but the variance just doesn't work.

I'm using this in the data item
(if([D1 6 Months] is missing) then (0)
Else([D1 6 Months]))
-
(if([D1 Period] is missing) then (0)
Else([D1 Period]))


It gives me weird numbers. I'm guessing it's because of the aggregation. I've tried loads of combinations but none work.

Can anyone help me please?
Title: Re: Can't get a simple minus calculation to work
Post by: blom0344 on 24 Feb 2012 02:19:08 AM


total(case when [D1 6 Months] is null then (0) else [D1 6 Months] end) -
total(case when [D1 Period] is null then (0) else [D1 6 Period] end)



Set aggregation type of the dataitem to calculated
Title: Re: Can't get a simple minus calculation to work
Post by: barrysaab on 24 Feb 2012 03:04:42 AM
thedon_1,did it worked for you.Thanks
Title: Re: Can't get a simple minus calculation to work
Post by: thedon_1 on 24 Feb 2012 09:48:21 AM
I tried that but it didn't work. I was previously doing my calculation before joining the 2 queries and then bringing the results into the final query.

I changed that so the calculation is done inn the final query and that sorted it out (Aggregation set to calculated). It must have been something to do with the join.


Thanks
Title: Re: Can't get a simple minus calculation to work
Post by: blom0344 on 24 Feb 2012 09:53:37 AM
Perform calculations within the same set. Do not expect correct results over multiple sets