Monday, January 7, 2013

Crosstab VS Subreports

Salam,

I have developed reports using open source iReport software over the years. Sometimes, the report's design require developer to use crosstab function. It happens when we need column and row both to be dynamic. Usually we have number of column fixed and row will be dynamic. If you still don't get me, please see the image below :-
The above example show that the column is fixed(Total) and the row(Country) is dynamic(will be populate base on data). For each country, we want to know how many customer exist. Now, let see the 2nd example :-

The above example show that the both country and month is populated base on data.
Now, we can accomplish this via crosstab or subreports. See below for the advantages and of both solutions.

Crosstab :
  • Fast way and easy to use if you understand the concept
  • Can add sub column and sub row
  • Can add total by sub column and sub row
Subreports :
  • Easier than crosstab(for beginners)
  • Able to generate row eventhough it has no data for that month(perhaps u want to display 0)
Bear in mind that you may need many subreports in order to satisfy the design. I always think that crosstab is the best solution.Anyway, other people might think the other way around.

Adios..