COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cognostechie on 31 Jan 2011 07:16:45 PM

Title: Default Selection
Post by: cognostechie on 31 Jan 2011 07:16:45 PM
Trivial question for most of you  ;)

I have a Value Prompt for selecting the Year. I want the default selection to be the current year. Is there a way to tell RS to determine the current year ? Wrap an HTML item around the Prompt? or sort it descending and set the focus to the first item? any other way?

Thanks !
Title: Re: Default Selection
Post by: PRIT AMRIT on 31 Jan 2011 08:42:30 PM
there r quite a few work around though...

Pls have a look at the below link and see if it helps?

http://www.cognoise.com/community/index.php/topic,9773.msg32101.html#msg32101 (http://www.cognoise.com/community/index.php/topic,9773.msg32101.html#msg32101)


Thanks
P
Title: Re: Default Selection
Post by: melee on 01 Feb 2011 02:02:11 PM
Quote from: cognostechie on 31 Jan 2011 07:16:45 PM
Trivial question for most of you  ;)

I have a Value Prompt for selecting the Year. I want the default selection to be the current year. Is there a way to tell RS to determine the current year ? Wrap an HTML item around the Prompt? or sort it descending and set the focus to the first item? any other way?

Thanks !

PRIT makes a good suggestion. Here's mine though, in case you're looking for a direct answer.

http://nicbertino.com/?p=48
Title: Re: Default Selection
Post by: cognostechie on 01 Feb 2011 03:57:50 PM
Thanks PRIT and melee. I used PRIT's  suggestion and this one also works:

getFormWarpRequest()._oLstChoicesyear.selectedIndex = 1;

Sort the prompt descending so 2011 comes up on the top so it selects that.

I still have a problem. The prompts are on the report page so first time the report opens, the filter has to use the current year to filter the data. I don't want to use promptbuttonfinish() because it won't let the user choose the year again.
Title: Re: Default Selection
Post by: melee on 01 Feb 2011 04:15:51 PM
What version are you on?
Title: Re: Default Selection
Post by: cognostechie on 01 Feb 2011 04:49:29 PM
8.4   I am using a cube package. What expression would I use to filter the report for current year when it is run 1st time and then filter it based on what is selected from the Prompt.
The extract(year,current_date) won't work with cube package.
Title: Re: Default Selection
Post by: cognostechie on 01 Feb 2011 07:16:37 PM
I got it to work one way (either way) but not with a combination.

Created a data item with the expression - lastchild([ReportPeriod]) where [ReportPeriod] is the member from the tree. The name of this data item is 'Period' and the value will be the latest year.

Filter =

(?DatePrompt? < '' and [Date Dimension].[Year] = [Period])

OR

(?DatePrompt? > '' and [Date Dimension].[Year] = ?DatePrompt?)

Doesn't give any syntax error but still shows value that belong to an earlier Year