Author Topic: Preselection of a date prompt  (Read 1273 times)

Offline nugget

  • Full Member
  • ***
  • Posts: 47
  • Forum Citizenship: +0/-0
Preselection of a date prompt
« on: 19 Jan 2009 01:55:16 pm »
hi forum,

how is it possible to set a preselection on a date prompt. i have a dimension which includes serveral years e.g. 2006, 2007, 2008 an so on.

i want that the year e.g. 2008 is preselectet if the report runs.

i think its a little javascript code necessary.

the id of the prompt is "JAHR". can anybody help me with the code?

nugget
« Last Edit: 20 Jan 2009 01:22:28 pm by nugget »
Cognos 8.2

Offline angela

  • Senior Member
  • ****
  • Posts: 64
  • Forum Citizenship: +4/-0
Re: Preselection of a date prompt
« Reply #1 on: 21 Jan 2009 04:08:51 am »
I wouldn't use javascript as it's unsupported upon upgrade.

If it's just a year I'd go to the Year query that supplies it and and in the filter put something like:

Case [Year]
When 'Current Year'
Then extract(year,[DateField])
Else [DateField]
End

Then add a static choice of Current Year to your prompt.

Offline nugget

  • Full Member
  • ***
  • Posts: 47
  • Forum Citizenship: +0/-0
Re: Preselection of a date prompt
« Reply #2 on: 23 Jan 2009 01:31:51 pm »
Thx for your reply,

i found another solution for my problem! i insert the member-uniquename of the object e.g. 2009 in the defaultvalue of the prompt.

Cognos 8.2

Offline Rajaggopal

  • Senior Member
  • ****
  • Posts: 65
  • Forum Citizenship: +0/-0
Re: Preselection of a date prompt
« Reply #3 on: 11 Feb 2009 03:12:38 pm »
But if the user runs the report next year say 2010 and the default year selected is 2009, will it server his purpose, because you are hard coding 2009 to be the default value.

Offline nugget

  • Full Member
  • ***
  • Posts: 47
  • Forum Citizenship: +0/-0
Re: Preselection of a date prompt
« Reply #4 on: 12 Feb 2009 01:21:59 pm »
yes thats right but i found no better solution at the moment. any ideas?
Cognos 8.2

Offline Rajaggopal

  • Senior Member
  • ****
  • Posts: 65
  • Forum Citizenship: +0/-0
Re: Preselection of a date prompt
« Reply #5 on: 12 Feb 2009 03:44:08 pm »
How about the idea angela suggested? it suits ur needs?

Offline nugget

  • Full Member
  • ***
  • Posts: 47
  • Forum Citizenship: +0/-0
Re: Preselection of a date prompt
« Reply #6 on: 08 Apr 2009 02:23:52 pm »
i dont understand angelas solution.

can somebody tell me (step by step) what i have to do?

Cognos 8.2

Offline Manic

  • Full Member
  • ***
  • Posts: 5
  • Forum Citizenship: +0/-0
Re: Preselection of a date prompt
« Reply #7 on: 13 Apr 2009 05:36:13 pm »
Hi friends,

In simple oracle we can extract like below,
to_char(sysdate,'YYYY') from table_name.

But Cognos, have anyone tried the function of the "Closing period".it might be solve ur problem.

Offline maximumiq

  • Associate
  • **
  • Posts: 1
  • Forum Citizenship: +0/-0
Re: Preselection of a date prompt
« Reply #8 on: 25 Jun 2009 05:25:50 pm »
Was this solved, and if so, how ?

I have the same problem, and would hate to use javascript.


Offline nugget

  • Full Member
  • ***
  • Posts: 47
  • Forum Citizenship: +0/-0
Re: Preselection of a date prompt
« Reply #9 on: 14 Jul 2009 06:05:22 pm »
no i dont understand the posted solution by angela  >:(

Cognos 8.2

Online PaulM

  • Global Moderator
  • Statesman
  • *****
  • Posts: 586
  • Forum Citizenship: +81/-1
Re: Preselection of a date prompt
« Reply #10 on: 14 Jul 2009 06:56:41 pm »
Depending on the version of Cognos, and how you've structured the query, I can offer you a few possible solutions.

It looks like this is a dimensional query, are you using filters or slicers?

The easiest solution would be to simply place a prompt macro with a default selection into the slicer.

For example
Code: [Select]
#prompt('Year','memberuniquename','[CurrentYearMember]')#
If the user runs the report without selecting a year, it will simply default to [CurrentYearMember].