0

I have used iReport to create a simple JasperReport which I run on a JasperServer. It queries some fields from a number of MySQL tables based on their creation timestamp. I am providing the start and end timestamps of the period to cover in the report as parameters of type java.sql.Timestamp. This works fine.

I was asked to introduce the ability to show a break-down on weeks or days of the report data. I would like to get some ideas on where to start with this. At this point I don't think I can accommodate this 'break-down' in the report query, since this feature seems beyond what SQL is designed to do. I know this sounds like an OLAP drill through, but I would like to avoid OLAP if possible (steep learning curve, tight deadlines).

My first thought was to create a subreport for each week or day . But this would leave me with an arbitrary number of subreports (depending on the overall time period covered by the report, which varies at each execution), and as far as I can tell iReport does not support this.

Epicurus
  • 2,103
  • 7
  • 29
  • 39
  • Can you explain what you mean by break-down? Do you want to show total by type (day, week, etc...) or do grouping as in sql group-by? – user845279 May 22 '12 at 22:28
  • For instance, if I have one column showing the number of items sold for each product during a specified time period, I would like to break this column down into "how many items were sold in each week of this period". – Epicurus May 23 '12 at 07:10

1 Answers1

1

Here is one way to break the report down.

  1. Create another parameter, groupby, which holds the a value that designates the grouping requirement. The values can be numeric, string or whatever else as long as it corresponds to day, week, month, etc.. grouping available.
  2. Create a report group, breakdown, which will provide the breakdown. The group expression will depend on the groupby parameter. The expression is the date on the record except any detail finer than groupby value will be trimmed.
  3. Create a variable, total, that will sum the data in the records. The variable should be reset on breakdown group and can be printed in the breakdown trailer band.
  4. Make sure the sql queries sortby the date so that the groupby expression works.

Let me know if you have questions.

user845279
  • 2,794
  • 1
  • 20
  • 38