If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Default value prompt - dynamic value

Started by keating101, 26 Apr 2013 03:10:49 AM

Previous topic - Next topic

keating101

hello,

I have a report which has a value prompt as a month number (ie January = 1, Feb = 2 etc). I want to set the prompt to show by default the current month. ie if i ran the report today it would show by default 4 (which is april)

I have read a few other posts on the net that the way to do it is by setting the default option as a static choice.

I have created a static choice called "Current Month". I have set the default selection to "current Month". The problem I have is writing the code for the filter.

the code to extract the current month number is: cast(extract(month,current_timestamp),varchar(2))
my parameter is: pPeriod
my query for the prompt is: qPeriod
the period number is defined in the database as: [Project Transactions].[Time].[Period Number]

Any help would be greatly appreciated?

Thanks,
Shaun

yossiea

Take a look at this script I use to default the date to last month. All you would need to do is change the script to return the month number only.

<script language="javascript">
//Default date contains current month/year, so set day = 1
var dDate = new Date();
dDate.setDate(1);
//This goes back to last day of previous month
dDate.setDate(dDate.getDate()- 1);
//Now set day = 1 again
dDate.setDate(1)
pickerControlStartDate.setValue(getFormatDate(dDate, 0 , 'YMD'));
</script>