Cognos Analytics

Cognos Analytics

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

 View Only
Expand all | Collapse all

Hide a row based on a condition

  • 1.  Hide a row based on a condition

    Posted Mon July 31, 2023 03:43 PM
    Edited by Dn Pr Mon July 31, 2023 10:13 PM

    Is it possible to hide a row (detail or group) based on a condition?

    I have a requirement to do 2 list reports.

    In one I need to hide the details without any condition

    The second one needs to hide the Group based on 1 condition and then hide the details based on another condition.

    Any help is greatly appreciated.



    ------------------------------
    Dn
    ------------------------------



  • 2.  RE: Hide a row based on a condition

    Posted Mon July 31, 2023 04:06 PM
    You can create a single report, but have the two report pages illustrating how you want it to look both one condition vs the other. The apply conditional rendering one of page vs the other based on your conditional variable.

    Logan Whitaker

    PMO, HEB Supply Chain Planning & Operations

    o: 210.938.6043 m: 210.429.3181

    e: whitaker.logan@heb.com







  • 3.  RE: Hide a row based on a condition

    Posted Mon July 31, 2023 04:38 PM
    Edited by Dn Pr Mon July 31, 2023 10:12 PM

    Thanks for the response.

    I don't need to show the 2 reports in one. They will be two separate reports. But on each , I need to hide the rows differently.

    I need to know whether it is possible to hide a row based on a condition?



    ------------------------------
    Dn Pr
    ------------------------------



  • 4.  RE: Hide a row based on a condition

    Posted Mon July 31, 2023 05:41 PM

    Okay.  This is what I'm hearing you want:

    • 2 reports totally separate from each other; not just 2 report pages in same report.
    • Each of the 2 reports has a list object on the report page where you want to view the data differently.
    • Both list objects have the same source of data [query] supporting them.
    • You want the list for one report to conditionally exclude certain data based on a condition.

     

    Not to beat a dead horse, but the report that may exclude data based on a condition could still use two report pages within it which conditionally renders one versus the other based on your condition.  What you are saying is "conditional rendering" regardless of how you want to approach solving it.  Hence why I suggested checking out conditional page rendering.  Out of curiosity, what kind of condition are you planning to use, and, is it in the data or is it based on user or something?

     

     

     

     






  • 5.  RE: Hide a row based on a condition

    Posted Mon July 31, 2023 10:11 PM
    Edited by Dn Pr Mon July 31, 2023 10:11 PM

    Thanks for the response.

    In my reports, I have the same data source. One report I am grouping by OrderNo. Then, I am showing the summary for the ordenno (total amount, no of items...etc.). I have a parameter that says show details (Y/N). If user selects Y, I want to show the details. Otherwise, hide it.

    Apologies if I am not clear with this. I am new to Cognos Analytics and trying to create an actual report that needs rows hidden based on certain conditions.



    ------------------------------
    Dn Pr
    ------------------------------



  • 6.  RE: Hide a row based on a condition

    Posted Mon July 31, 2023 10:51 PM
    Think Im getting closer, but need to clarify a few more things:

    1. Are you using a regular 'ol report where you are having a prompt page for the user to select See Detail = Y/N first? Or are you using an Active Report for the user dynamically toggle between Y/N instead?

    2. Is your report intended to have many orders at once, or are you intended to display only 1 order (like if someone keys in an order number and its the one displayed)?

    3. If your report does show multiple orders, are you okay with the Y/N displaying the details, or hiding them, for all the orders displayed?

    Logan Whitaker

    PMO, HEB Supply Chain Planning & Operations

    o: 210.938.6043 m: 210.429.3181

    e: whitaker.logan@heb.com







  • 7.  RE: Hide a row based on a condition

    Posted Mon July 31, 2023 11:27 PM

    Not sure how your queries and report page are structured, but here is an example in regular 'ol report if this is what you were thinking.   Let me know if I'm tracking.

     

     

     

     

     






  • 8.  RE: Hide a row based on a condition
    Best Answer

    Posted Tue August 01, 2023 02:59 AM

    Firstly I would say Investigate the use of the new(ish) Data Table object. This is an object that allows the user to expand/collapse detail rows without a report author doing anything clever. You can start this in a collapsed  state too. It allows user filters and all kinds of fancy stuff.

    If a data table isn't suitable then you are down to using a parameter and conditional styles.  

    On the list select the 'List Columns Body Style Object:

    And apply a conditional style, something like :



    Where the Style has Box Type set to None. This will hide the detail rows:  

    The above is what most beginner report authors would do. But it isn't the best answer.

    In the above example my detail rows are Month. If the user doesn't want the detail rows then we return 12 months of detail and then just hide them. Whilst in my example this is a trivial amount or rows, imagine if my detail rows were order number. We could return millions of rows of detail to just hide them, a very poor report.

    To make the report better I would change the Month date item to be something like:

    case when ?pHideDetail? <> 'Hide Detail' then [Month] end

    I would then change the conditional style we had above to

    [Month] is null

    That way I am only using the param logic once in the query. If we change the parameter, or the parameter answers, I only have one object to edit.

    Lastly I would create a variable to Hide the month column in the no detail mode.

    Create a boolean variable based on the parameter. And use this as a render variable on the month column.



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



  • 9.  RE: Hide a row based on a condition

    Posted Tue August 01, 2023 01:05 PM

    I should have also added... that when you want to hide the details, you probably would want the summary rows to no longer look like summary rows. For example this list now looks pretty poor:  

    You can use a conditional style to format these summary rows differently. This single list now needs to:

    1. have a calculation to remove the month from the query for efficiency
    2. hide the detail rows
    3. hide the detail columns
    4. reformat the summary rows so they look like detail rows when the details arent needed.

    But, whilst this is all very clever, to make one list do everything, an alternative is to simply just have two distinct lists. One for the detail view, the second for the view without details. This means you have two simple lists, rather than one complicated list and complicated query. You then show the appropriate list using a render variable.

    For me, in the above case of a list with Year, Month and Quantity I would go the two list approach. There is a time for the single list approach, and for me that is when the user wants to hide numerous detail columns, and they can control which individual detail columns to switch on/off.



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



  • 10.  RE: Hide a row based on a condition

    Posted Tue August 01, 2023 03:11 PM
    Edited by Dn Pr Tue August 01, 2023 03:11 PM

    Excellent. It works. Much appreciated for all the replies. 

    I need to keep the details as the requirements might be changed to display certain detail rows for specific items even when show detail parameter is set to No. 

    Thanks a lot. This is what I was looking for.



    ------------------------------
    Dn Pr
    ------------------------------