Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying current Month in the default selection for a value prompt

Status
Not open for further replies.

meenatikare

Programmer
Feb 21, 2005
8
CH
In a prompt page, I have a value prompt which displays Month & Year i.e. like 2007 January format.

The default selection for the value prompt should be the current month, which keeps changing for the every month.

Since the default value stores only static how can this be changed to dynamic.

Hoping for a early reply
 
Hi,

You can't do this directly without resorting to javascript. Would the following be an acceptable alternative?

1. Add a query item 'Mth Start' to calculate the first day of the month from a date prompt - _first_of_month(?Date Entered?)
2. Add a query item 'Mth End' to calculate the last day of the month from the same date prompt - _last_of_month(?Date Entered?)
3. Add a filter to the report using these as start and end values - [Your Date Item] between [Mth Start] and [Mth End]

The date prompt generated will always default to the current date.

MF.
 
Another non-javascript alternative:
(1) sort the data in your prompt query in reverse chronological order, and add a data item using the Rank() or Running-count() function (wrapped in the to_char() function) so that the current month is always associated with the value '1'. Use this data item as the "Use" value for your prompt and set 1 as the default for the prompt.
(2) to decode the prompt value back to its time period (1=current month, 2=last month, and so on) create another query which contains your actual time period column(s) and the function-based data item, and filter it with the prompt value (filter may need to be at query level)
(3) use a tabular reference and filters to join to the query in (2) above on your time period column(s) in any tabular models where you need your time filter.

This assumes ReportNet but a similar approach should be possible in Cognos 8. This has potential negative performance implications depending on your data but I've has good luck with it in several reports. It's good for reports which are both scheduled and run interactively since the saved prompt value '1' will always return the current period in the schedule (though if you view the saved prompts, you will see the display value for whatever month was current at the time the prompts were saved).
Steve

 
Thanks to everyone for there reply.

I tried doing this with the help of Java Script.Where I still have doubt regarding the performance issue.Hoping a reply on this from guru's in the forum.

Intially I added a HTML text item and included following script.

The query item that displays prompt has to be sorted in descending order.

Where FromDate in the script is the name of the prompt.
<script>

//Declare local variables
var objFromPrompt = document.forms["formWarpRequest"].elements["_oLstChoicesFromDate"];

objFromPrompt.options[2].selected = true;

setTimeout('listBoxFromDate.checkData()', 100);
</script>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top