Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Asking operator for parameter from user
ManishJ
Hi..<br />
<br />
I have created a report where users can provide certain parameters based on which the where conditions are applied in the dataset query. In such a case, I have to hardcode the operator in the query. For example<br />
<br />
Select * from my_table where create_date <strong class='bbc'>></strong> ?<br />
<br />
How to make a report where user can decide if she wants to get the data with create_date <strong class='bbc'>less than</strong> provided date(parameter), or perhaps where create_date <strong class='bbc'>between </strong>certain dates.<br />
<br />
Thanks
Find more posts tagged with
Comments
thuston
What version are you using?<br />
I know Actuate 11 is set to have Ad-Hoc parameters. I'm not sure what BIRT version they were introduced in.<br />
<br />
If your version does not support Ad-Hoc, then you'll have to Script the query to adjust the WHERE.<br />
You could use another Pick list parameter to offer operator selection (<,>,=,range)<br />
Here is an example where we modified DataSet BeforeOpen to replace dummy values (111=111) with our own Filters.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if ( params["isInternational"] == 'true' ) {
theQuery = "AND ACCOUNT.BillingCountry NOT IN ('USA','Canada')";
theQuery2 = "Terr.Country__C = dbo_ACCOUNT.BillingCountry"
} else {
var theQuery = "AND dbo_ACCOUNT.BillingCountry IN ('USA','Canada')";
var theQuery2 = "t.Zip_Code__c = SUBSTRING(dbo_ACCOUNT.BillingPostalCode,0,6)"
}
this.queryText = new Packages.java.lang.String(this.queryText).replaceAll("AND 11111 = 11111", theQuery);
this.queryText = this.queryText.replace("22222 = 22222", theQuery2);</pre>