US and Worldwide: +1 (866) 660-7555
Results 1 to 4 of 4

Thread: conditional linebreaks?

  1. #1
    Join Date
    Apr 2007
    Posts
    1,938

    Default conditional linebreaks?

    Hi,

    I have a rather weird request, and i'm not sure if it should be done in reporting, or in the data source.

    So; I have a list of events and associated times. What i'd like to do is:

    if current event time is more than x minutes of previous event time

    then insert a blank line

    So; Can that be done in the report? Or would I have to process the data before coming to the report engine and insert dummy blank lines actually into the data set?

    Thanks!
    Dan

  2. #2
    Join Date
    Mar 2003
    Posts
    7,591

    Default

    Well, you definitely need the previous value before you can do anything on the reporting level. We do not ship with anything built-in for that, so you would end up writing a function for that. (Or use Kettle, or maybe some SQL magic, or ..)

    Once you have the current and the previous value in the same row, then inserting the blank is easy. In the most simple case, just add a empty band with a defined minimum height, and add the following formula as visibility trigger: "=ABS([current] - [prev]) > TIME(0, 5, 0)".

    Inserting dummy blank lines could cause trouble as it messes up groupings and calculations. Although your first report may not need them, later on requirements may change and then you would have to correct that solution.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  3. #3
    Join Date
    Apr 2007
    Posts
    1,938

    Default

    ah that sounds great. Yes i do expect the data may have to be massaged through kettle first anyway, for other reasons too.

    I'll give that a go and report back!

  4. #4
    Join Date
    Apr 2007
    Posts
    1,938

    Default

    Hi Taqua,

    I can't actually get the above code to work. I get the linebreak all the time even when i dont expect it.

    How can I add a field that will show me the value of =(ABS[current]-[prev]) ?

    I also tried a bsh expression to get the difference and that didnt seem to return a number at all:

    <code>
    Object getValue() {
    Number req = (Number) dataRow.get ("APP_SERVER_REQUEST_DATE_UTC");
    Number prev = (Number) dataRow.get ("PREVIOUSEVENTTIME");
    return new Number (req - prev);
    }

    </code>

    Confused!

    Update: I have it working now if i pass in a number as part of the data set which is the number of minutes difference.
    So; all i need to do now (ideally) is work out how to calculate that number in the report rather than having to pass it in as part of the dataset... Seems im pretty close...


    Thanks!
    Dan
    Last edited by codek; 09-29-2008 at 11:40 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •