COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: V i n c e n t on 27 Mar 2013 04:56:01 AM

Title: Running Total
Post by: V i n c e n t on 27 Mar 2013 04:56:01 AM
Hi,

I need your help to do a running-total

I want that :
MONTH CUSTOMER REVENUE  RUNNING-TOTAL
    01         APPLE       5000              5000
    02         APPLE          0                 5000

I have that :
MONTH CUSTOMER REVENUE  RUNNING-TOTAL
    01         APPLE       5000              5000

There is no value for this customer in the second month, then the running-total dont work with something who don't exist.

How to do what i want ??

Thanks for helping me.


Title: Re: Running Total
Post by: blom0344 on 27 Mar 2013 07:11:53 AM
If the row is brought in from the query, then try to coalesce the value to change null to 0 and perform the running total on this expression
Title: Re: Running Total
Post by: V i n c e n t on 27 Mar 2013 08:01:49 AM
Can you explain in more détail please ?
Title: Re: Running Total
Post by: calson33 on 28 Mar 2013 11:09:16 AM
You will need to join your results set with a query that returns a list of months.





"MONTHS LIST""DATASET MONTH""DATA"
115000
1- (COALESCE(DATA,0)5000 (Running total)
Title: Re: Running Total
Post by: V i n c e n t on 28 Mar 2013 11:42:44 AM
Thanks Calson33, i'll try this tomorrow
Title: Re: Running Total
Post by: blom0344 on 28 Mar 2013 02:39:52 PM
running totals are generated by the Cognos server engine, not within the SQL executed. So if you want to add non-existing rows, then you need to do a little more than use a list of months (otherwise you will get an additional row with a null value for the customer.

There is an elegant solution using a union : bring in all combinations of month and customer (with a crossjoin) in a second query with a zero for the revenue. Union this with the original query and use the result set to calculate the running total