Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 


#Product
#Analytics
#CognosAnalytics
#Analyticstools
#TechXchange Partner
#TechXchange Session
#TechXchange Presenter
#AI
 View Only
Expand all | Collapse all

Cognos 11.1.7

  • 1.  Cognos 11.1.7

    Posted 07/25/23 07:44 PM

    I have a complex crosstab where now I need a row above to calculate and provide a numeric value to the next row.  I am unsure how to accomplish this easily.

    This crosstab has case statements for the date buckets.  It is using a relational model.

    Any ideas would be helpful.



    ------------------------------
    Jenifer Broughton
    ------------------------------


  • 2.  RE: Cognos 11.1.7

    Posted 07/25/23 09:06 PM
    Using a LAG function in SQL is one way to accomplish this. This approach may require writing the underlying query in SQL to perform all the aggregations you want in the report page instead of relying on the crosstab aggregations. If you shared the SQL for the underlying query we might be able to tweak it for you to accomodate this. If you went this route, you wouldnt even need to bother with a crosstab and instead just use a list (since the aggregations would already be done in the query).

    Logan Whitaker

    PMO, HEB Supply Chain Planning & Operations

    o: 210.938.6043 m: 210.429.3181

    e: whitaker.logan@heb.com







  • 3.  RE: Cognos 11.1.7

    Posted 07/26/23 07:29 AM

    @Logan Whitaker  Thanks for this info.  I have used the lag in the past and was hoping to be able to use here.  I cannot.  Like you mention, I am not able to.  This final query has 3 unions in the backend.  None of which are sql.  Unfort, I only have until friday to complete this report.  I'm racking my brain with the easiest solution.



    ------------------------------
    Jenifer Broughton
    ------------------------------



  • 4.  RE: Cognos 11.1.7

    Posted 07/26/23 08:51 AM

    in which case the answer will very much depend upon what source data you have. For example, lets say your column above are A,B,C,D.

    Then you can easily calculate column B by just doing runningtotal(a) - runningtotal(c) - runningtotal(d)



    ------------------------------
    Marc Reed
    ------------------------------



  • 5.  RE: Cognos 11.1.7

    Posted 07/26/23 09:25 AM

    Assuming you have the columns as measures then...



    ------------------------------
    Marc Reed
    ------------------------------



  • 6.  RE: Cognos 11.1.7

    Posted 07/26/23 09:31 AM

    @Marc Reed  Thank you.  Let me try this!!!  Back to you soon!



    ------------------------------
    Jenifer Broughton
    ------------------------------



  • 7.  RE: Cognos 11.1.7

    Posted 07/26/23 10:18 AM

     @Marc Reed  Hi Mark.  It's calculating, but the numbers are not right.



    ------------------------------
    Jenifer Broughton
    ------------------------------



  • 8.  RE: Cognos 11.1.7
    Best Answer

    Posted 07/26/23 10:18 AM
    Edited by Jenifer Broughton 07/27/23 08:05 AM

    Tried the technique on your numbers and it seems to work...

    I think the numbers in my list match your orginal post. If you've typed in the formula exactly as above, then it could be down to the order that the running totals and moves are working out.

    Do you have to use a xtab? Lists are easier to control the orders.

    You could try applying a presort in the query.

    Debugging the solution should be quite easy.

    Just change the calc to running-total( [a] ) and see if this simple running total works. If this works then do the running count [ C + D)

    and build it up.

    Seeing what running count A gives will give you an indication of if its a row order problem.

    Additionally, your original post only has 4 columns in it. If you look in my solution I only use 3 of those 4 columns. Could it be that you have accidentally used too many columns in my formula.

    ------------------------------
    Marc Reed
    ------------------------------



  • 9.  RE: Cognos 11.1.7

    Posted 07/26/23 10:28 AM

    @Marc Reed  Thanks for the quick reply..   Let me create a list and see if the new calc works there.



    ------------------------------
    Jenifer Broughton
    ------------------------------



  • 10.  RE: Cognos 11.1.7

    Posted 07/26/23 10:33 AM
    Edited by Marc Reed 07/27/23 02:09 AM

    edited : removed report XML as solution was used and worked.



  • 11.  RE: Cognos 11.1.7

    Posted 07/26/23 01:09 PM

    Thank you!!  I have been in meeting after meeting today.  Thanks for the extra info.  I will digging into this more shortly.  You have been wonderful!



    ------------------------------
    Jenifer Broughton
    ------------------------------



  • 12.  RE: Cognos 11.1.7

    Posted 07/26/23 02:12 PM

    @Marc Reed  I am very grateful for your quick assist on this!  The calculation you gave me is now providing the correct numbers in the right quarters.

    I can't thank you enough for the quick and correct response!!!! 

    Thank you Thank you Thank you!!

    Jen



    ------------------------------
    Jenifer Broughton
    ------------------------------



  • 13.  RE: Cognos 11.1.7

    Posted 07/26/23 02:49 AM
    Edited by Marc Reed 07/26/23 09:30 AM

    EDITED.
    This answer was deleted as it added no value to the conversation



  • 14.  RE: Cognos 11.1.7

    Posted 07/26/23 07:31 AM

    @Marc Reed  Hi Mark, Thanks for the reply.  Maybe I am not following.  I need the line2 that totals 532 for that total of 532 to appear on line3.  And the line 3 total to appear on line 4 etc..



    ------------------------------
    Jenifer Broughton
    ------------------------------



  • 15.  RE: Cognos 11.1.7

    Posted 07/26/23 01:55 PM
    Make two same queries (1,3). Sort both of them. Create column "running-count" (2) in first query, and "running-count + 1" in the second (4). Join those two queries by "running-count" columns. Then everything will be off by one row (5). Then you can do any calculations you want.
    Offset join between 2 tables


    ------------------------------
    Milan Milovanovic
    ------------------------------



  • 16.  RE: Cognos 11.1.7

    Posted 07/27/23 02:09 AM

    @Milan Milovanovic If there is a need to move a value down a row the moving total technique shown above is far less effort.

    moving-total( [data item],2) - [data item]



    ------------------------------
    Marc Reed
    ------------------------------