在 Cognos BI 中,如何选择下拉参数的第一个/最后一个元素作为默认值?
我绞尽脑汁试图找到一种简单的方法来做到这一点,我想我将不得不求助于程序化解决方案(如果可能的话)。
我正在使用 Cognos BI 8.4,并设置了一个查询来检索数据库表中的所有不同日期。我还有一些报表参数,它使用该查询来填充两个值提示,每个提示对应开始日期和结束日期。
我需要的是将列表中的第一个日期设置为默认日期(对于开始日期参数)或列表中的最后一个日期(对于结束日期参数)。例如,如果表中的日期范围是 2011-01-15
到 2011-06-03
,则开始日期参数应默认为前者和结束日期参数应默认为后者。
我可以将默认值设置为特定的已知值,但是由于该列表是查询的结果,因此我事先不知道这些值。如果我使用 1970-01-01 作为默认开始日期,它不会将其设置为最早的日期,它只是完全忽略该值。
我在参数屏幕上得到的内容是这样的:
+-------------+ +-----------+
Date range: | From date |V| | To date |V|
+-------------+ +-----------+
+-------------+ +-----------+
Yellow/red: | 70% |V| | 90% |V|
+-------------+ +-----------+
您可以看到黄色和红色阈值填充正常,因为它们是静态内容(50
到 100
,步骤为5
),不是动态的。因为我知道该下拉列表存在某些值,所以我可以将默认值设置为静态值,例如 70
或 90
。
但是,如前所述,动态参数不会以这种方式运行,而是在我尝试设置的默认值不在填充下拉列表的查询中时恢复到“未选择默认值”视图。
如何将默认值设置为特定于查询的值而不是静态值。使用 BIRT,我只需在查询后运行一些 Javascript 代码,即可根据检索到的数据更改 ROM 插槽。 Cognos BI 是否有类似的做事方式(如果有,是什么)?
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许这会对您有所帮助:
http://it.toolbox.com/wiki/index.php/Dynamically_Select_the_First_Value_in_a_Value_Prompt
另外,请检查以下一些答案:
http ://businessintelligence.ittoolbox.com/groups/technical-function/cognos8-l/first-value-in-drop-down-prompt-as-default-4102889
Maybe this will help you:
http://it.toolbox.com/wiki/index.php/Dynamically_Select_the_First_Value_in_a_Value_Prompt
Also, check some answers from this:
http://businessintelligence.ittoolbox.com/groups/technical-functional/cognos8-l/first-value-in-drop-down-prompt-as-default-4102889
请注意,诸如此类的 Javascript 解决方案存在潜在的跨浏览器问题,并且几乎从不跨 Cognos 版本兼容。
Cognos 在 10.2 中通过 提示 API。
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.