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)
Group by but not required
hossman51
I'm trying to create a group by but make the group by not required allowing the user to chose whether or not they want the reported to be grouped or not.
What I've done is created a group by and I'm passing a non-required parameter to the report that tells the report what field to group the report by. Because this group by parameter is not required I would like to tell the report to group by the field passed or not group the report at all if a NULL value is passed.
Here's my script in the expression builder where the parameter "groupBy" is set by the user to the field they want to group the report by, but if they pass NULL then I don't want to group the report at all and just list all the records in a list report.
if(params["groupBy"].value != null){
row[params["groupBy"].value]
}else{
//don't group the report at all
}
If I submit the NULL value in the parameter and thus that NULL value gets to the group by I get the following error.
- Fail to compute value from sort, group or filter expression.
A BIRT exception occurred: There are errors evaluating script "row[params["groupBy"].value]":
Invalid bound column name: null. (<inline>#1).. See next exception for more information.
There are errors evaluating script "row[params["groupBy"].value]":
Invalid bound column name: null. (<inline>#1).
data.engine.ScriptResult.WrongSystemComputedColumn ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: Fail to compute value from sort, group or filter expression.A BIRT exception occurred: There are errors evaluating script "row[params["groupBy"].value]":Invalid bound column name: null. (<inline>#1).. See next exception for more information.There are errors evaluating script "row[params["groupBy"].value]":Invalid bound column name: null. (<inline>#1). at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1121)
Does anyone know how I get the report to not group by anything when NULL is passed as the parameter value?
Thanks,
Dustin
Find more posts tagged with
Comments
mwilliams
Hi Dustin,
Are you just using a text box type parameter? Or a list type parameter with all the options they could group by in it?
hossman51
I'm giving the user a list box that they can select from as to what field they want to group by. But I want this group by to not be required or be able to pass a null value to the reports group by expression so that it doesn't try to group the report and just display all the results in a native list.
Thanks,
Dustin
mwilliams
Dustin,
If you require it and add an option of "No Grouping" to your list, this would solve the issue. Not sure what BIRT uses as it's "null value" to be able to compare it yet. If I figure that out, I'll let you know.
hossman51
I can add the "No Grouping" option to the list but then the value of the group by field is set to empty string and the report doesn't know how to group by row.
Is there a way for me to say if "No Group" then don't have the report try to group the data.
Thanks,
Dustin
mwilliams
Dustin,
If you check for the value of "No Grouping" in the expression for the group by doing something like the following, I don't think it will group if "No Grouping is Selected"
if (params["Group"] == "No Grouping"){
}
else{
row[params["Group"].value];
}
Then, you could use a similar expression to determine if you'll display anything in the group header of the table.
hossman51
Now I got you. That will work. Thanks again for all your help I greatly appreciate it.
Dustin
mwilliams
Dustin,
No problem. Let me know if you have any other questions.