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)
Add "AND" to query if criteria met
drewsheez
I am new to BIRT. Currently, I am putting together a report that has 5 parameters. One of the parameters is a radio button with two options. I want to be able to add an "AND" statement to my query if one of the options is selected. If the other option is selected, I want to leave the "AND" statement out of the query.
Is there any way to accomplish this?
I have looked through the documentation and found filters, but it doesnt seem as if I will be able to accomplish this using a filter. I also do not believe I can specify an "AND" statement using the ? marker with parameters as I receive an error when just placing another ? in the query.
Any thoughts?
Find more posts tagged with
Comments
mwilliams
Hi drewsheez,
In your beforeOpen script for your dataSet, you can add an 'AND' statement depending on the values of your parameters. You can add the and statement with something like:
if (params["paramName"] == true){
this.queryText = this.queryText + " and blah";
}
Hope this helps.
drewsheez
Thanks Michael!
I will give this a shot. I'm assuming that this would automatically append to the end of the query currently being used given the code:
this.queryText = this.queryText + " and blah";
... which means I wouldn't need to specify where to add the text in the query other than this code, correct?
I appreciate your help!
mwilliams
That is correct. Be sure to put a space between the quote and the 'and' since it will append it directly to the back of the query string.
drewsheez
It worked perfectly! Thanks for your help!
mwilliams
Not a problem. Let us know whenever you have questions!