COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: bignadad on 26 Sep 2013 05:41:15 PM

Title: Need to base a data item on a filter
Post by: bignadad on 26 Sep 2013 05:41:15 PM
I want to include Last Year results in my list.

Im using this as my filter
[YearLY] = [Invoice].[Year] - 1

Now, how can i associate my data item to read from this?

My current data item is this
[Invoice].[Net Price]*[Invoice].[Quantity Shipped]

I duplicated that data item and called it LineTotalLY. How can i get it to only read last year?
Title: Re: Need to base a data item on a filter
Post by: Gopinath on 27 Sep 2013 07:42:53 AM
Remove the filter and add a case statement in your  LineTotalLY data item as

CASE WHEN [YearLY] = [Invoice].[Year] - 1
THEN [Invoice].[Net Price]*[Invoice].[Quantity Shipped]
ELSE 0
END
Title: Re: Need to base a data item on a filter
Post by: bignadad on 27 Sep 2013 11:34:17 AM
CASE WHEN [YearLY] = [Invoice].[Year] - 1
THEN total([Invoice].[Net Price]*[Invoice].[Quantity Shipped])
ELSE 0
END

I tried that on my LineTotalLY data item.

I made a list and put Return, LineTotal, LineTotalLY

But LineTotal and LineTotalLY are the same
Title: Re: Need to base a data item on a filter
Post by: blom0344 on 29 Sep 2013 02:41:40 PM
Try:

total(CASE WHEN [YearLY] = [Invoice].[Year] - 1
THEN [Invoice].[Net Price]*[Invoice].[Quantity Shipped]
ELSE 0
END)