COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: tradeex on 29 Jan 2015 04:19:52 AM

Title: [RESOLVED] current year vs prior year
Post by: tradeex on 29 Jan 2015 04:19:52 AM
Hello -

I have a relational model where I have a prompt for month and a prompt for year. In the report I need to show current month and same month prior year. current month shows fine but not prior year.
my Month calcs look like:

month = tOTAL(IF( [VERSION ID]='ACTUAL') THEN ([AMOUNT]) ELSE (0))

PY month = tOTAL(IF( [VERSION ID]='ACTUAL' and [year]=?year? - 1) THEN ([AMOUNT]) ELSE (0))
but PY month doesn't work.

My year prompt is the basic prompt. Please help been working on this for past 2 days and can't get it to work.

Thanks
Title: Re: current year vs prior year
Post by: Virgin on 29 Jan 2015 05:33:50 AM
Hello,

You use the parameter ?Year? - 1
if you want to have the prior year , try with :

PY month = total(if([VERSION ID] = 'ACTUAL' and [year] = (cast(?year?; integer) - 1) then ([AMOUNT]) else (0))

Title: Re: current year vs prior year
Post by: Robl on 29 Jan 2015 06:07:49 AM
The code looks fine.
Are you filtering the data based on the year and month?
Title: Re: current year vs prior year
Post by: tradeex on 29 Jan 2015 06:51:19 AM
Yes I am filtering the data based on year and month. So the user will select month = JAN and Year = 2015 and report should show Jan Month Sales, YTD 2015 and prior year Jan 2014. And the prior year is giving me issues since year = 2015.
Title: Re: current year vs prior year
Post by: tradeex on 29 Jan 2015 06:56:41 AM
I tried the

total(if([VERSION ID] = 'ACTUAL' and [year] = (cast(?year?; integer) - 1) then ([AMOUNT]) else (0))

but gave me parsing errors. Did not work. What am I missing?
Title: Re: current year vs prior year
Post by: MFGF on 29 Jan 2015 06:58:24 AM
Quote from: tradeex on 29 Jan 2015 06:51:19 AM
Yes I am filtering the data based on year and month. So the user will select month = JAN and Year = 2015 and report should show Jan Month Sales, YTD 2015 and prior year Jan 2014. And the prior year is giving me issues since year = 2015.

What filter syntax are you using? I'm guessing your filter for year is [Your year item] = ?YearParameter? - can you confirm? If so, that's where your issue lies.

MF.
Title: Re: current year vs prior year
Post by: tradeex on 29 Jan 2015 07:13:52 AM
Hi -

My filter is like this :

[YEAR] in (?year?)
Title: Re: current year vs prior year
Post by: MFGF on 29 Jan 2015 09:35:42 AM
Quote from: tradeex on 29 Jan 2015 07:13:52 AM
Hi -

My filter is like this :

[YEAR] in (?year?)

So if the user selects (say) 2015 from the prompt, this is then substituted into the parameter so your filter ends up as being [YEAR] in (2015)

Hopefully you can see that this will limit the rows coming into your report to only those for 2015, so anything you try to calculate for 2014 will not have any supporting data in the query.

MF.
Title: [RESOLVED} current year vs prior year
Post by: tradeex on 30 Jan 2015 04:31:10 AM
I was able to figure it out. I had to change my filter to do between ?year? and ?year? - 1 and adjust my data item calculations