COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: hespora on 06 Nov 2019 11:43:51 AM

Title: running-total() loses sort in query reference or join
Post by: hespora on 06 Nov 2019 11:43:51 AM
Hi there,


situation: simple query with one dimension, one measure coming from my source. In the query, the measure's sort property is set to "sort descending", and a query calculation of

running-total(
  [measure]
  for report
)

is correctly determining the running total, starting with the highest values.

My problem: I do not actually need the running total in this query, but I need to join it to a different query. However, when I do that, the sort order is ignored. Same happens when I just point a query reference to the query where I'm determining the running total.

Why is that? And how can I force cognos to use the sorting as specified in the original query?
Title: Re: running-total() loses sort in query reference or join
Post by: hespora on 06 Nov 2019 11:48:19 AM
I've looked at the generated sql for both queries. The original query quite correctly is built as

SUM("Measure")
  OVER(
    ORDER BY
      "Measure" DESC
  ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS "running total"


On the other hand, when I look at the referencing query, the same snippet becomes

SUM("Measure")
  OVER(
    ORDER BY
      100 ASC
  ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS "running total"


Title: Re: running-total() loses sort in query reference or join
Post by: Andrei I on 06 Nov 2019 12:09:58 PM
Can you reproduce this issue using Cognos Cloud and share your Report XML?