Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Choose colum from dataSet with Report Parameter
Siki
Hi
Can someone tell me if it is possible to choose column from table in data Set with Report parameter
ex. query
select ?
from tableName
where .....
or some other solution
The user should choose from parameter which column to be shown in the report
Find more posts tagged with
Comments
Tubal
In my experience, you can't use a parameter to replace a column name in your SQL statement.<br />
<br />
But you can modify the query before you send it to your database.<br />
<br />
Each dataset has a beforeOpen script event where you can modify your query based on a paramater. Your query is stored in 'this.queryText'<br />
<br />
So say your query was<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>select column1
from myTable</pre>
<br />
In your dataset's beforeOpen script, you could do something like:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if (params["thecolumnIwanttoshow"]=="column2") {
this.queryText = this.queryText.replace("column1","column2")
}</pre>
<br />
And that would replace any instance of "column1" with "column2" making your new query<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>select column2
from myTable</pre>