COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: philelmousse on 22 Mar 2012 10:03:42 AM

Title: text box prompt, current year for default value
Post by: philelmousse on 22 Mar 2012 10:03:42 AM
Hello,

I have a text box prompt to fill with the year. It's possible to set the default value with the current year ?

Thanks
Title: Re: text box prompt, current year for default value
Post by: Grim on 22 Mar 2012 12:26:41 PM
Javascript version:
http://www-01.ibm.com/support/docview.wss?uid=swg21342970

Other solution from devworks forum:
http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14679605
Quotecreate one data item
and write coding like
case when cast(extract(year,yourdataitem),varchar(4))=cast(extract(year,{sysdate}),varchar(4))
then '0'
else '-1'
end
the above code whenever the date equals to system date will give you 0
and other date give as -1

now in the "Date Value Prompt" in properties
Use Value:the above data item
Display Value:your date data item
Default Selection:0

now you run the report it will always give you current year.
Title: Re: text box prompt, current year for default value
Post by: philelmousse on 11 May 2012 04:49:39 AM
Thanks.

I created that data item :

CASE
WHEN cast([REPORTING LAYER].[Calendar Time].[Calendar Time].[Year].[year],varchar(4))=cast(extract(year,current_date),varchar(4))
then '0'
else '-1'
end


It returns

CurrentMonth CurrentYear year
5 -1 2009
5 -1 2010
5 -1 2011
5  0 2012

So it seems to work but when I run the report the default year is 2011

In the value prompt for useValue I selected that data item, for the display value i selected [REPORTING LAYER].[Calendar Time].[Calendar Time].[Year].[year] and for the default '0'... That is weird
Title: Re: text box prompt, current year for default value
Post by: philelmousse on 11 May 2012 04:57:30 AM
it works... it was just the cache.
Title: Re: text box prompt, current year for default value
Post by: philelmousse on 11 May 2012 08:32:58 AM
But the issue is that the used value will be 0 and I need the year and the month to filter the queries
Title: Re: text box prompt, current year for default value
Post by: philelmousse on 26 Jun 2012 03:39:50 AM
still the same issue because i need to create schedule for my reports every month. I need to find how dynamiclly fill my prompts for the current month and the current year
Title: Re: text box prompt, current year for default value
Post by: philelmousse on 27 Jun 2012 03:26:31 AM
So i add a static choice with a use value ' ' and a display value 'current month'. But in framework manager i use a stored procedure with a month parameter. And i dont know how to pass something like that in the stored procedure : (?Month? = ' ' and [DATABASE LAYER].[calendar_time].[month] = extract ( month, current_date  ))) or ([DATABASE LAYER].[calendar_time].[month]  =?Month?)