Community
Participate
Working Groups
Created attachment 244548 [details] Report demonstrating the problem Our reports often contain "detail tables". E.g. based on the ClassicModels demo database, a master-detail report showing customers and their corresponding orders. For a customer without orders, the report should hide the "orders" table (otherwise it would still show the table header). The usual way to achieve this is to - create a COUNT aggregate "AggrCount" on the detail tables binding tab. - as visibility expression for the table, use !AggrCount. This works with BIRT 3.7.1 and 4.2.1. However, with BIRT 4.3.0 and BIRT 4.3.2, the AggrCount contains the value 1 instead of 0, and thus the report output is incorrect (still shows the empty table). I'll add an example report. Notify the customer 125 "Havel & Zbyszek Co" on page 2 in the PDF output. For this customer, there are no orders. However, the yellow table header is still shown. This is incorrect behavior in BIRT >= 4.3
Note: The error does not occur if the "expression" field of the COUNT aggregate binding is not empty, e.g. with an expression row["CUSTOMERNUMBER"] Nevertheless, I think this is an undesired change in behavior and should be fixed. Searching and modifying hundres of existing reports is not really an option.
Another possible workaround is to use this visibility expression instead (works with 4.3.0 and 4.2.1): 0 != row[0] // row[0] contains the "row index": 0,1,2,.... // If there are no rows, the value is -1. But what is the "official way" to hide a table/list if the data set doesn't contain rows? And anyway, COUNT should return 0 if there are no rows. In 4.3, COUNT returns 1 in this case (discovered with our logging framework).
It looks like you have to specify an expression in the aggregation binding "Count": <structure> <property name="name">Count</property> <property name="dataType">integer</property> <property name="aggregateFunction">COUNT</property> <list-property name="arguments"> <structure> <property name="name">Expression</property> <expression name="value" type="javascript">row["ORDERNUMBER"]</expression> </structure> </list-property> <property name="allowExport">true</property> </structure> The COUNT function behaves bad without an expression.
Yes, I know (see comment 2). But this is still different behavior in comparison to BIRT 4.2.1 and to the SQL analogon SELECT COUNT(*) FROM ... which counts just the rows. Whereas the query SELECT COUNT(COLUMN_X) FROM ... counts the rows where COLUMN_X is not null. I guess this is the same with in BIRT. This makes a huge difference if there isn't a NOT NULL column in the select list.
Sorry, I have overseen your second comment. As a workaround for datasets that don't have a not nullable column, you can use an implicit __rownum column in the COUNT function expression: row.__rownum
Well, using row.__rownum is similar to using row[0] (see comment 2 again). Neither trick seems to be well-documented, and I'm a bit pessimistic here: maybe in one of the next version the developers consider this a bug instead of a feature. That's why I asked for the official way to do this. And anyway, it's only a workaround for the regression.