Conditional display of columns
Apologies If this is a duplicate. But I've tried searching for this query on the forums & have been unsuccessful so far.<br />
<br />
I have a report which takes in a parameter. Based on the value of the parameter, different queries are executed.<br />
Each of these queries has different fields in the select clause.<br />
<br />
How do I Map & display the columns in my report based on the parameter selected.<br />
<br />
e.g. <br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if(param.value == "ABC")
{
sqlQuery = "select a.field1, b.field2, c.field3 from table tableA a, tableB b, tableC c"
}
else
{
sqlQuery = "select d.field4, e.field5, f.field6 from table tableD d, tableE e, tableF f"
}</pre>
<br />
I've tried using the visibility property to hide a column based on the parameter in another report. But in that case one of the 2 queries had an extra column in the select clause.<br />
<br />
i.e. the original queries were like this<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if(param.value == "ABC")
{
sqlQuery = "select a.field1 as Branch, b.field2, c.field3 from table tableA a, tableB b, tableC c"
}
else
{
sqlQuery = "select b.field2, c.field3 from table , tableB b, tableC c"
}</pre>
<br />
Which i changed to...<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if(param.value == "ABC")
{
sqlQuery = "select a.field1 as Branch, b.field2, c.field3 from table tableA a, tableB b, tableC c"
}
else
{
sqlQuery = "select '' as Branch, b.field2, c.field3 from table , tableB b, tableC c"
}</pre>
<br />
Along with the visibility property change to hide the Branch column if "ABC" was not selected.<br />
<br />
<br />
Any help will be appreciated.