paxdiablo
paxdiablo

Reputation: 881513

In Cognos BI, how do I select first/last element of a dropdown parameter to be the default?

I've racked my brain trying to find an easy way to do this and I think I'm going to have to resort to a programmatic solution (if that's even possible).

I'm using Cognos BI 8.4 and have a query set up to retrieve all distinct dates from my database table. I also have some parameters for the report which uses that query to populate two value prompts, one each for start and end date.

What I need is to have the first date in the list be the default (in the case of the start date parameter) or the last date in the list (for the end date parameter). For example, if the dates in the table range from 2011-01-15 to 2011-06-03, the start date parameter should default to the former and the end date parameter should default to the latter.

I can set defaults to specific known values but, since the list is the result of a query, I don't know the values in advance. If I use 1970-01-01 for the default start date, it doesn't set it to the earliest date, it just ignores that value altogether.

What I get on the parameter screen is something like this:

            +-------------+  +-----------+
Date range: | From date |V|  | To date |V|
            +-------------+  +-----------+
            +-------------+  +-----------+
Yellow/red: |       70% |V|  |     90% |V|
            +-------------+  +-----------+

You can see that the yellow and red thresholds populate okay since they're static content (50 through 100 in steps of 5), not dynamic. Because I know that certain values exists for that dropdown, I can set the default to a static value, like 70 or 90.

However, as mentioned, the dynamic parameters do not act this way, instead reverting to the "no default selected" view if the default I try to set is not in the query which populated the dropdown.

How do I set the default to a query-specific value rather than a static one. With BIRT, I just had some Javascript code run after the query to change the ROM slots based on the data retrieved. Does Cognos BI have a similar way of doing things (and, if so, what is it)?

Upvotes: 1

Views: 5333

Answers (2)

toddsonofodin
toddsonofodin

Reputation: 513

A caution that Javascript solutions such as this have potential cross-browser issues, and are almost never cross-Cognos version compatible.

Cognos addresses this in 10.2 with the Prompt API.

Upvotes: 0

Related Questions