COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: RandomHunter on 20 Dec 2012 02:23:20 AM

Title: [SOLVED] Help with rolling-total
Post by: RandomHunter on 20 Dec 2012 02:23:20 AM
Hi all,

I'm working on a report that uses a prompt page with a date selection. The user chooses a period (YYYY-MM) and based on that period, the revenue has to be shown from a year ago until the selected date. I use right(), left() and cast() functions to extract the years/months, but how can I create the YTD'ish function to get the correct revenue.
I hope my problem is stated clear enough.

Here's my solution: I used a case expression to show the revenue when the date is between the selected date minus 12 months and the selected date. Expressions looks like this.

case
when [Date]  between _add_months (_make_timestamp ([SelectedYear],[SelectedMonth],01), -12) and _make_timestamp ([SelectedYear],[SelectedMonth],01)
then [Gross Revenue]