【问题标题】:Cognos Report Studio: How can I change the image displayed based on a query output?Cognos Report Studio:如何根据查询输出更改显示的图像?
【发布时间】:2021-06-29 04:52:09
【问题描述】:

使用 Cognos Report Studio:

我有一个返回两个数字的查询,我需要根据这两个数字显示一个向上、向下或直箭头。存储在服务器中的图像。

这是我的条件:

If (num1 > num2) then (green arrow)
If (num1 < num2) then (red arrow)
If (num1 = num2) then (straight arrow)

我尝试使用名为vImagestring 变量,条件如下:

case
   when (num1 > num2) then (GreenArrow.png)
   when (num1 < num2) then (RedArrow.png)
   when (num1 > num2) then (StraightArrow.png)
end

num1num2 作为查询结果。 那些.png 文件是我的答案列表。

在我的报告中,我将 Image 布局元素与 URL Source Variable 设置为 Image 变量。

但当我运行 HTML 时,报告元素返回空白。

我尝试在 URL 源变量对话框中选择和取消选择值,但似乎没有任何效果。

有什么建议吗?

【问题讨论】:

  • 您听说过报表变量和条件块吗?
  • 请使用样本数据提供样本报告规范。这有助于确定具体问题并确保您已经完成了相关工作,因此我们会以最少的努力来回答问题。
  • 如果规范太大而无法在此处发布,您可以从您的问题中链接到其他服务(例如pastebin.com)。

标签: report cognos cognos-bi


【解决方案1】:

鉴于要求只是向上和向下箭头,我真的根本不会打扰图像。只需将 ascii 箭头复制到 if 子句中。 https://unicode-table.com/en/sets/arrow-symbols/#up-arrows。完成后,使用条件样式调整字体颜色。

case
   when (num1 > num2) then (▲)
   when (num1 < num2) then (▲)
   when (num1 > num2) then (▲)
end

【讨论】:

    【解决方案2】:

    您不需要定义变量。

    对于您的图片栏:
    设置 URL 来源 | 报告表达式的源类型属性。
    将表达式设置为如下所示:

    '/Graphics/' + 
    case
        when [Query1].[num1] > [Query1].[num2]
            then 'Green'
        when [Query1].[num1] < [Query1].[num2]
            then 'Red'
        else 'Straight'
    end
     + 'Arrow.png'
    

    进行调整以适应图像的实际路径。
    您还需要考虑如何制作 URL 对输出格式的影响。 HTML 图像 URL 由客户端浏览器评估。 Excel 或 PDF 输出中的图像 URL 由 Cognos 服务评估。图像可能以一种输出格式出现,而不是另一种。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多