08-20-2002, 12:40 PM
This is going to be a little hard to explain but here goes:

If I have a table with various fields ordered by NAME and then BY NAME2.

The report is grouped by NAME - naturally the report generated list its items by NAME then NAME2 order since this is how the data is in the table. My question is how to I count distinct NAME2 in NAME.

I dont have any items so all I do is have a footer on the NAME group which contains the number of items, a sum of one of the fields and THEN THE NUMBER OF DISTINCT NAME2.

Trying to use a subgroup is not working for me any help is very much appreciated. I have bought that documentation and would like to congraulate the coders on a very usefull package. The xml definintion is ingenious since reports can be added without the need to change code in my main application. BRILLIANT

08-20-2002, 03:23 PM

if your data is queried by SQL from a database, try the following statement:


if this gives a result, you can use the result in the column NAME2COUNT as data for your report. So you dont have to write a function.

This is working because you don't have any items and so you will not lose any valuable information for your report.

In any other case, you would have to write a counting function which should count all specific occurences of NAME2:

List data = ...;

public void groupStarted (ReportEvent ...)
data.clear ();

public void itemsAdvanced(ReportEvent ...)

String name2Value = <value of field name2>;
if (data.contains(name2Value) == false)
data.add (name2Value);

public Object getValue()
return new Integer (data.size());

Every distinct value of name2 is added to the list, the number of elements is equals to the number of distinct values in column Name2 for the specific group. Whenever a new group starts, the result is reseted.

Your implemtation has to make sure, that cloning is working correclty, or your results are messed up.

Have more fun,
said Thomas