COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: COGNOSBC on 26 Apr 2013 12:39:35 PM

Title: based on selected months, use the counts from the last month selected
Post by: COGNOSBC on 26 Apr 2013 12:39:35 PM
Hi,  in one of my report I have startdate and enddate prompts.

my requirement is: based on selected months, use the counts from the last month selected

for ex: if I run the report for Jan2013, feb2013 and mar2013, my report has to show the counts for Mar 2013 only.  how to get that out of selecting 3 months, get only last selected month data.

Thanks,
Title: Re: based on selected months, use the counts from the last month selected
Post by: raj_aries on 26 Apr 2013 02:28:19 PM
use _add_months(?enddate?,-1) and for going back to one month.

i.e, [Date] between _add_months(?enddate?,-1) and ?enddate?

or

use write a case statement in the count column as below

count(case then [Date] between  _add_months(?enddate?,-1) and ?enddate? then [dataitem you want to count] end)
Title: Re: based on selected months, use the counts from the last month selected
Post by: COGNOSBC on 29 Apr 2013 01:11:59 PM
Hi Raj,  thanks for your advise and help.
I have updated my current year filter with following expression:
[Date] between _add_months(?enddate?,-1) and ?enddate?
current year for example 2013 march count worked perfectly. 

what should I change in the expresion for prior year march (2012 March)  counts.

my current expression for prior year is
[date] between _add_years (?startyear?,-1) and _last_of_month (_add_years (?endyear?,-1))

Title: Re: based on selected months, use the counts from the last month selected
Post by: sthabinash on 30 Apr 2013 03:06:51 AM
 for prior year march (2012 March)  counts you could use the following expression

count(case then [Date] between  _add_years(_add_months(?enddate?,-1),-1) and _add_years(?enddate?,-1) then [dataitem you want to count] end)