cognoscognos-10

How can I make a column display certain text based on another columns data in an IBM Cognos report?


For example, the structure of the report is like this:

<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-c6of{background-color:#ffffff;border-color:inherit;text-align:left;vertical-align:top}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
</style>
<table class="tg">
  <tr>
    <th class="tg-c6of">Identifier</th>
    <th class="tg-0pky">Codes</th>
    <th class="tg-0pky">Mixed Codes?</th>
  </tr>
  <tr>
    <td class="tg-0pky">123456789</td>
    <td class="tg-0pky">111</td>
    <td class="tg-0pky" rowspan="3">YES</td>
  </tr>
  <tr>
    <td class="tg-0pky" rowspan="2"></td>
    <td class="tg-0pky">222</td>
  </tr>
  <tr>
    <td class="tg-0pky">333</td>
  </tr>
  <tr>
    <td class="tg-0pky">987654321</td>
    <td class="tg-0pky">222</td>
    <td class="tg-0pky">NO</td>
  </tr>
</table>

I would like to hide the "Codes" column completely and only have Cognos display a Yes or No in the "Mixed Codes?" column if there are mixed codes attached to the identifier. So far I have not been able to get this to work with an IF statement in the data expression as the data is pulled on a per-row basis.

Thank you.


Solution

  • Remove [Codes] from the query.
    [Mixed Codes?] should be defined as

    CASE
        WHEN count(distinct [namespace].[query subject].[Codes]) > 1 THEN 'YES'
        ELSE 'NO'
    END