标签: cognos-10

IBM Cognos Report Studio:从提示"default text"参数中选择值提示默认值

我有一个引用参数'Year_Parameter'的值提示符,以及一个列有一列(数据项表达式)的列表,它以这种方式引用与值提示符相同的参数:

#prompt('Year_Parameter')#
Run Code Online (Sandbox Code Playgroud)

值提示有一些静态选择:2011年,2012年和2013年.因此,当我运行我的报告,并在显示报告页面之前弹出的提示页面中输入2012时,会在值提示中自动选择2012显示报告页面时的选项列表.

此外,如果我将2012放入默认选择列表中,则不会显示任何提示页面,并且现在还会在显示报告时自动选择2012作为值提示.

但是,如果我从默认选择列表中删除2012,并将我的数据项表达式更改为以下任一表达式:

#prompt('Year_Parameter', 'token', '2012')#
#prompt('Year_Parameter', 'token', 2012)#
#prompt('Year_Parameter', 'string', 2012)#
#prompt('Year_Parameter', 'string', '2012')#
Run Code Online (Sandbox Code Playgroud)

...当2012被指定为默认选择时,没有弹出提示页面,但是没有为值提示自动选择值.值提示显示其默认标题文本:参数名称 - Year_Parameter".

记住提示函数定义:

prompt(prompt_name,datatype,defaultText,text,queryItem,trailing_text)

任何人都知道为什么会这样,更重要的是如何通过在数据项表达式中指定它来为如何选择值提示的默认选择的解决方案?

是因为prompt()宏只是尝试获取参数'Year_Parameter'的值,但是它本身不会用值填充参数?该参数必须由某个值提示符给出(在提示页面上或嵌入在报表页面中).

因此,提示函数的defaultText参数将永远不会填充参数本身,但在参数没有(有效)值的情况下由此特定提示函数返回?

非常感谢您的任何输入!

编辑:找到有关如何为参数动态分配默认值的说明.

http://cognosknowhow.blogspot.no/2013/04/how-to-dynamically-set-up-default-value.html

最后:我最终使用以下Javascript来动态选择值提示并更新报告:

<script type="text/javascript">
// This function updates the report dynamically for the current year
// The function is wrapped inside a setTimeout call in order to avoid an error caused by too frequent requests
setTimeout(function updatePrompt() {
    var oCR = cognos.Report.getReport("_THIS_");
    var yearPrompt = oCR.prompt.getControlByName("YearPrompt");
    var selectedValue = yearPrompt.getValues()[0];

    if (typeof …
Run Code Online (Sandbox Code Playgroud)

cognos cognos-bi cognos-10

5
推荐指数
1
解决办法
3万
查看次数

Cognos相当于excel的sumif()函数

我熟悉Excel和SQL,但对Cognos不熟悉.我正在[Total Margin]为每个人做一个有条件的总和[Item Code].此结果应显示在每一行的每一行上.我在Cognos中尝试了两种方法,并在Excel中进行了概念验证.请参阅下面的单个样本数据[Item Code].

数据截图

总项目保证金A(Cognos)

case
when [free of charge flag] = 'FALSE'
then total([Total Margin] for [Item Code])
else null
end
Run Code Online (Sandbox Code Playgroud)

这里的问题是TOTAL结果不正确,并且无法显示在第2行.

总项目保证金B(Cognos)

total([Total Margin] for [Item Code],[free of charge flag])
Run Code Online (Sandbox Code Playgroud)

这里TOTAL结果在大多数行上是正确的,但在第2行上是不同的.

总项目保证金C(Excel)

=SUMIFS([Total Margin],[Item Code],'10001430',[free of charge flag],FALSE)
Run Code Online (Sandbox Code Playgroud)

所以我可以使用excel SUMIFS公式得到我想要的结果.我需要编写哪些Cognos查询才能直接从Cognos获得相同的结果?

cognos totals cognos-8 sumifs cognos-10

4
推荐指数
1
解决办法
6567
查看次数

标签 统计

cognos ×2

cognos-10 ×2

cognos-8 ×1

cognos-bi ×1

sumifs ×1

totals ×1