COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Sofie on 08 Jul 2019 04:07:49 AM

Title: Total Data Items
Post by: Sofie on 08 Jul 2019 04:07:49 AM
Hi

For my report I have created 3 Data Items which all give a total. Now I have to add those 3 Data Items up, but I don't seem to manage to do so. Does anyone have an idea how to do this? I've tried already different options, but all of them return an empty value.

Data Item 1 : Booked Project Hours
Expression : TOTAL(
IF ([Project Name] NOT STARTS WITH 'Z_IT' AND [Project Name] <> 'Non-Project Work')
THEN ([Hours])
ELSE NULL)

Data Item 2 : Booked Movement Hours
Expression : TOTAL(
IF ([Project Name] STARTS WITH 'Z_IT One Movement')
THEN ([Hours])
ELSE NULL)

Data Item 3 : Booked IT2.0 Hours
Expression : TOTAL(
IF ([Project Name] STARTS WITH 'Z_IT Project IT')
THEN ([Hours])
ELSE NULL)

Thank you for taking the time to look into this problem!
Title: Re: Total Data Items
Post by: oscarca on 08 Jul 2019 06:53:21 AM
Try:
IF ([Project Name] NOT STARTS WITH 'Z_IT' AND [Project Name] <> 'Non-Project Work')
THEN( total([Hours]))
ELSE(NULL)

or:
IF ([Project Name] NOT STARTS WITH 'Z_IT' AND [Project Name] <> 'Non-Project Work')
THEN( aggregate([Hours] for report))
ELSE(NULL)
Title: Re: Total Data Items
Post by: Sofie on 08 Jul 2019 08:06:10 AM
Hi oscara

Thank you for the reply.
The outcome of the 3 different Data Items is OK now, but for some reason they still don't add up to a global total.

To make the sum of the 3 Data Items, I'm using the following expression : [Booked Project Hours] + [Booked Movement Hours] + [Booked IT2.0 Hours]. Fot this sum, no data is returned...

I've tried with different expressions already, but without any result...
Title: Re: Total Data Items
Post by: Francis aka khayman on 10 Oct 2019 01:04:14 PM
most probably there is a null in one of your addends. try using else (0) instead
Title: Re: Total Data Items
Post by: Sofie on 07 Nov 2019 04:13:30 AM
Thank you all for the suggested solutions, unfortunately none of them gave the correct result.

However, I discussed this issue with one of our Daptiv consultants (the tool for which we are using Report Studio), and he gave me the solution. Apparently, I used the wrong option in the Aggregate and Rollup aggregate functions (I used None where I had to use Automatic).