Cognos Analytics

Cognos Analytics

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

 View Only
  • 1.  Hide/remove column in Cross tab report

    Posted Mon March 31, 2025 03:26 AM

    Hi, I have following report in  Cognos. Where 202402 and 202502 are coming from field "Period", Global is coming from field "Visibility", Sales is coming from field "Sales" and Field "Difference" is a calculated field. Now my requirement is I want to hide/remove field "Difference" from Last Year Period and will show only for current year. Could you please let me how can I do this? Thanks in Advance.

    Current Report:

      202402 202502
      Global Global
      Sales Difference Sales Difference
    USA 1000 200 1200 100
    UK 2000 300 2500 200
    Poland 2500 350 3000 300

    Required Report

      202402 202502
      Global Global
      Sales Sales Difference
    USA 1000 1200 100
    UK 2000 2500 200
    Poland 2500 3000 300


    ------------------------------
    Max Ray
    ------------------------------


  • 2.  RE: Hide/remove column in Cross tab report

    Posted Mon March 31, 2025 05:23 AM

    Create a prompt that the user chooses in the prompt page with Hide or Show Difference. Then select the Difference field (the whole field) create a Conditional Advance Style where ParamDisplayValue('p_Hide') = 'Hide' and in this condition in the formatting options apply Non-Inline..

    GDM



    ------------------------------
    Giovanni Mazzucato
    ------------------------------



  • 3.  RE: Hide/remove column in Cross tab report

    Posted Mon March 31, 2025 06:14 AM

    Thanks for your reply. But I want to hide it for last year only. For example, I have one prompt page where user can enter Period values. If user can enter 202502 then report will show values for 202502 and 202402. Now my requirement is, I want to show the difference for current year 202502 but want to hide/remove for last year which is 202402. How can I implement this?



    ------------------------------
    Max Ray
    ------------------------------



  • 4.  RE: Hide/remove column in Cross tab report

    Posted Mon March 31, 2025 07:45 AM

    It depends on many factors:
    1. is the Datasource relational or Olap
    2. how did you apply the query filters
    If I understand correctly how you set up the query that feeds the list/crosstab that you have on the page you can:
    a. add a page filter that limits to the current and previous year
    b. directly enter the calculation of the difference by inserting a CASE that performs the delta but operating at the lowest level of period YYYYMM using the prompt value and deriving the previous year from the prompt itself
    c. delete the field relating to the previous period if it is not needed because having it



    ------------------------------
    Giovanni Mazzucato
    ------------------------------



  • 5.  RE: Hide/remove column in Cross tab report

    Posted Tue April 01, 2025 02:29 AM
      |   view attached

    What sound's quite a simple question is actually quite a tricky problem. This is because you have nested columns within your crosstab.  

    I will assume that you have built your crosstab by nesting measures Revenue and Difference under the year.

    If I simulate your problem with Go Sales with a relational data source.

    Here is the original crosstab in design mode:  

    and gives this data :

    We want to hide the Difference Column in everything but the last column. I have simulated this by just using a conditional style based on the year. 

    You can see in this conditional style that the selected items are only visible. And when this runs it produces :  

    This has indeed hidden two of the difference columns! We only have one difference column. But all of the columns have been shifted to the left. The revenue columns are no longer lined up with the year columns! We have three Revenue columns and one difference column.  

    And this is why this problem is really complex for nested columns. Whilst we can hide columns, all column get shifted across!

    Because of the nesting I don't believe we can solve this problem using the original crosstab design and conditional styles.

    But there IS a solution. It's a bit complicated, but it is possible.  

    How did I achieve this?

    The trick is in the data. Instead of nesting measures, I have nested a data item:  

    If I look at the data and pick a country, then the rows of data I get back for this are :

    You can see I only get a Difference Row in 2018 - the last year. And this is the trick, you need to get your data looking like this.

    You need your query to return a Revenue row for every year, and a difference row for only the last year.

    In this example I have achieved this like so:

    My crosstab is based on Query 1 :

    Query 1 is a union of a Revenue Query, and a Difference Query.  

    The revenue query looks like:  

    1. You can see it includes all years.
    2. The Measure Name column simply contains 'Revenue'
    3. The Measure column simply contains the revenue measure.

    The difference query looks like:

    1. It only contains the last year
    2. Measure name is simply 'Difference'
    3. The Measure contains the difference calculation.

    Obviously these are simple examples and your query for difference will need to do something like Year = Maximum( Year ).

    But this is the framework for achieving what you want.  

    I have attached this example report.



    ------------------------------
    Marc Reed
    Reporting Lead
    ------------------------------

    Attachment(s)

    txt
    crosstab.txt   8 KB 1 version


  • 6.  RE: Hide/remove column in Cross tab report

    Posted Wed May 07, 2025 02:02 PM

    Hello I popped in on this thread because I've had this issue before myself. Thank you for the really detailed explanation --- I really love this approach to it! Really creative and easy to wrap my mind around so I'll try this out in the future.

    Best,



    ------------------------------
    STEPHANIE REYES | Reporting & Analytics Specialist | Cognos Enthusiast |
    Building advanced, production-ready reports in Cognos Analytics since Aug 2024.
    https://www.linkedin.com/in/stephanie-marie-reyes
    ------------------------------