Hide a column when value is 0 which uses page break

Emy
Emy
edited February 11, 2022 in Analytics #1
<p>Hi,</p>
<p> </p>
<p>  I have one report in which one column A is splitted by column B.I need to hide a column  A when no data.I tried visibility functionality & it hided column A for all spliting of  column B.Column A is a aggregated field.</p>
<p> </p>
<div>
<p>For Eg, I need to hide "column 2" in that rows having no data.</p>
<p> </p>
<p><span style="margin:0px;color:rgb(0,0,139);">Column</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(128,0,0);">1</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(0,0,139);">Column</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(128,0,0);">2</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(0,0,139);">Column</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(128,0,0);">3</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(0,0,139);">Column</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(128,0,0);">4</span></p>
<p><span style="margin:0px;color:rgb(128,0,0);"> 10                                  13         15</span></p>
<p><span style="margin:0px;color:rgb(128,0,0);"> 23                                  13         19</span></p>
<p> </p>
<div>At the same time,I need to show "Column 2" when there is data</div>
<div>
<p> </p>
<p><span style="margin:0px;color:rgb(0,0,139);">Column</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(128,0,0);">1</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(0,0,139);">Column</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(128,0,0);">2</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(0,0,139);">Column</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(128,0,0);">3</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(0,0,139);">Column</span><span style="margin:0px;color:rgb(0,0,0);"> </span><span style="margin:0px;color:rgb(128,0,0);">4</span></p>
<p><span style="margin:0px;color:rgb(128,0,0);"> 15                                 36         5</span></p>
<p><span style="margin:0px;color:rgb(128,0,0);">2                 71               53         9</span></p>
</div>
</div>
<p> </p>
<p> </p>
<p>Regards,</p>
<p>Emy</p>

Comments

  • <p>Hi Emy,</p>
    <p> </p>
    <p>To hide a column in a table component, you can add this script to your report on the <strong>onPrepare </strong>Event of the table</p>
    <p> </p>
    <p><strong><span style="color:#7f0055;"><span style="font-family:consolas;"><span style="font-size:10pt;">if</span></span></span></strong><span style="color:#000000;"><span style="font-family:consolas;"><span style="font-size:10pt;"> (<my condition></span></span></span><span style="color:#000000;"><span style="font-family:consolas;"><span style="font-size:10pt;">){</span></span></span></p>
    <p>  <strong><span style="color:#7f0055;"><span style="font-family:consolas;"><span style="font-size:10pt;">this</span></span></span></strong><span style="color:#000000;"><span style="font-family:consolas;"><span style="font-size:10pt;">.getColumn(1).getStyle().display = </span></span></span><span style="color:#2a00ff;"><span style="font-family:consolas;"><span style="font-size:10pt;">"none"</span></span></span><span style="color:#000000;"><span style="font-family:consolas;"><span style="font-size:10pt;">;</span></span></span></p>
    <p><span style="color:#000000;"><span style="font-family:consolas;"><span style="font-size:10pt;">}</span></span></span></p>
    <p> </p>
    <p> </p>
    <p>Your condition can be for instance the count of not null value of the column 2. If this value is 0 (= only null or no value), you hide the column</p>
    Warning No formatter is installed for the format ipb
  • <p>Hi,</p>
    <p> </p>
    <p>    I have attached a sample report.In that,column should be hide for value 0.Visibility function doesn't workout.Please review it & let me know.</p>
    <p> </p>
    <p>Thanks,</p>
    <p>Emy</p>
  • Clement Wong
    Clement Wong E mod
    edited December 23, 2015 #4
    <p>Emy,</p>
    <p> </p>
    <p>Your sample design referenced an XLS which did not exist.  However, it was easy to recreate with sample data.</p>
    <p> </p>
    <p>The easiest way to hide a column based on the data you provided is the following:</p>
    <p> </p>
    <p>1. Create a Computed Column (in my example it's called "Column B COUNT")</p>
    <p>     A.  Change the Data Type to Integer</p>
    <p>     B.  Set the Aggregation to COUNT</p>
    <p>     C.  Set the Expression to Column B</p>
    <p> </p>
    <p>2. Select Column B in the Layout</p>
    <p> </p>
    <p>3. Check the Hide Element option under Properties > Visibility</p>
    <p> </p>
    <p>4. Change the Expression from "true" to:</p>
    <pre class="_prettyXprint">
    if (row["Column B COUNT"] == 0)
        true;
    else
        false;</pre>
    <p>In the sample design, I changed Column B's background color to red to highlight so that you can see that it's working.</p>
    <p> </p>
    <p>If you change the underlying data and add a single value in Column B, then Column B will appear in the output.</p>
    Warning No formatter is installed for the format ipb
  • <p>Hi Emy,</p>
    <p> </p>
    <p>sorry for the late answer.</p>
    <p>Here is an additional example based on Clement's explanation</p>
    <p> </p>
    Warning No formatter is installed for the format ipb