Cognos Report Studio中的交叉表问题

时间:2019-10-16 11:56:54

标签: cognos

在交叉表Cognos中计算增长。我需要将上一年度的值带入本年度的列。请帮助我。

-322,129,132.49应该在2018年成为PY1列。

enter image description here

1 个答案:

答案 0 :(得分:0)

缺少信息:

  • Cognos版本
  • 样本数据
  • 列名
  • 2017年PY1应该是什么?

...但是我会尽力的。

我认为您所说的是2017 PY1应该为0,2018 PY1应该为-322,129,132.49。如果正确的话...

调整查询以在正确的年份返回PY1。这可能涉及将多个查询连接在一起。这是要考虑的示例SQL:

select a.[year]
, a.unnamed_code_value
, coalesce(b.PY1, 0) as PY1
, a.en_Amount
from (
    select [year]
    , unnamed_code_value
    , sum(en_Amount) as en_Amount
    from table1
    group by [year]
    , unnamed_code_value
) a
left outer join (
    select [year] + 1 as 'year'
    , unnamed_code_value
    , sum(en_Amount) as PY1
    from table1
    group by [year] + 1
    , unnamed_code_value
) b on b.[year] = a.[year]
   and b.unnamed_code_value = a.unnamed_code_value