How to hide a column when value is 0 which uses column grouping

Options
Emy
Emy
edited February 11, 2022 in Analytics #1
<p>Hi ,</p>
<p>  </p>
<p>      I have a report which uses column grouping.I need to hide a column when value is 0.</p>
<p> </p>
<p>I have attached sample report.</p>
<p> </p>
<p>In this,column B is splitted by column grouping as B1,B2,B3,B4.The row for B column is aggregation.</p>
<p>I used labels instead of crosstab to split B column.but i can't hide a column when no value for any column of B..B has all 4(B1,B2,B3,B4) value on some scenario & has any 2(B2,B3) or 3 (B1,B3,B4) value on other scenario.How to hide a column when no value ?.I tried visibility functionality to hide a column,but it doesnot work for me.Is any other option to solve that?</p>
<p> </p>
<p> </p>
<p>Thanks,</p>
<p>Emy</p>

Comments

  • Channamari
    edited November 12, 2015 #2
    Options
    <p>You can actually use a JS function along with the visibility property.. Something like this on selection of the column that you wish to hide.. Suppose i wanted to hide Column B2, i would use something like this as the function..</p>
    <p> </p>
    <p>if(params["B1"].value==2){</p>
    <p>   true;</p>
    <p>}else{</p>
    <p>  false;</p>
    <p>}</p>
    <p> </p>
    <p>Hope it helps..</p>
  • Emy
    Emy
    edited November 27, 2015 #3
    Options
    <p>Hi ,</p>
    <p> </p>
    <p>  Thanks for your reply.But it does not work for me.</p>
    <div> </div>
    <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>
  • <p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">Hi Emy,</p>
    <p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"> </p>
    <p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">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 style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"> </p>
    <p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><strong><span style="color:rgb(127,0,85);"><span style="font-family:consolas;"><span style="font-size:10pt;">if</span></span></span></strong><span style="color:rgb(0,0,0);"><span style="font-family:consolas;"><span style="font-size:10pt;"> (<my condition></span></span></span><span style="color:rgb(0,0,0);"><span style="font-family:consolas;"><span style="font-size:10pt;">){</span></span></span></p>
    <p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">  <strong><span style="color:rgb(127,0,85);"><span style="font-family:consolas;"><span style="font-size:10pt;">this</span></span></span></strong><span style="color:rgb(0,0,0);"><span style="font-family:consolas;"><span style="font-size:10pt;">.getColumn(1).getStyle().display = </span></span></span><span style="color:rgb(42,0,255);"><span style="font-family:consolas;"><span style="font-size:10pt;">"none"</span></span></span><span style="color:rgb(0,0,0);"><span style="font-family:consolas;"><span style="font-size:10pt;">;</span></span></span></p>
    <p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><span style="color:rgb(0,0,0);"><span style="font-family:consolas;"><span style="font-size:10pt;">}</span></span></span></p>
    <p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"> </p>
    <p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">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. Of course, this can be applied for any column of your table</p>
    Warning No formatter is installed for the format ipb
  • <p>Hi ,</p>
    <p> </p>
    <p>    Thanks for your reply but your solution does not work.</p>
    <p> </p>
    <p>Regards,</p>
    <p>Emy</p>
  • <p>Hi Emy,</p>
    <p> </p>
    <p>can you upload an example with data of what you want exactly to achieve.</p>
    <p> </p>
    <p>Regards</p>
    Warning No formatter is installed for the format ipb
  • Emy
    Emy
    edited December 16, 2015 #7
    Options
    <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>