【问题标题】:Cognos equivalent of excel's sumif() functionCognos 相当于 excel 的 sumif() 函数
【发布时间】:2015-01-03 00:35:05
【问题描述】:

我熟悉 Excel 和 SQL,但对 Cognos 很陌生。我正在为每个[Item Code][Total Margin] 进行条件求和。此结果应显示在每个项目的每一行上。我在 Cognos 中尝试了 2 种方法,在 Excel 中尝试了概念证明。有关来自单个 [Item Code] 的示例数据,请参见下文。

总项目边距 A (Cognos)

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

这里的问题是TOTAL结果不正确,只是无法在第二行显示。

总项目边距 B (Cognos)

total([Total Margin] for [Item Code],[free of charge flag])

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

项目总边距 C (Excel)

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

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

【问题讨论】:

    标签: cognos sumifs cognos-10 cognos-8


    【解决方案1】:

    试试

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

    【讨论】:

    • 成功了,谢谢!制定新系统的查询语法有时会令人沮丧。似乎这里需要一个嵌套的 CASE 。
    • Cognos 10 中的工具提示有时几乎毫无用处,因为您永远看不到如何真正使用 {expression} 的示例。这是一个很好的例子。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-21
    • 1970-01-01
    • 2022-01-02
    • 2020-07-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多