Hitachi Vantara Pentaho Community Forums
Results 1 to 7 of 7

Thread: Defining two reports in the same xaction?

  1. #1
    Join Date
    Apr 2010
    Posts
    127

    Default Defining two reports in the same xaction?

    Hi all,
    I was wondering if it's possible to link two (slightly) different reports in an action sequence, so to be able to pick one depending on a parameter value.
    In fact it seems the resource (.prpt file) must be named "report-definition" in order to work, and if you name both with that same name the first is always chosen (regardless of "Report Specification" field in Pentaho Report component).

    Thank you.

  2. #2
    Join Date
    Oct 2007
    Posts
    235

    Default

    The following should work with the old xml report types, however the new (.prpt) ones it most likely won't, you will probably be better off just creating two reports.

    While the thing passed into the report component must be named that it doesn't have to be resource, you can do it as a variable. If you have a look at the dynamic report tech tip you should see an example where it builds up the entire xml report in to a variable and passes it into the report component.

    If you create two resources and have an if block around two template steps you can read the two different resources into the one variable depending on your parameters and then use that as the input to the report component.

    Good luck

    Wil
    SQL: as much of a standard as the English language

  3. #3
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    There is nothing hard-coded - so anything that works for the old jfreereport-component should also work for the simple-reporting-component. But of course, it wont work for the prpt-only mode.

    If you want to use prpt-only mode, then you can simply get away with two or more (banded)-subreports defined in the same report - and a bunch of visible-style-expressions on them to select which one should be shown.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  4. #4

    Default

    Just a thought.
    What about change report-definition value with javascript?

  5. #5
    Join Date
    Apr 2010
    Posts
    127

    Default

    Thank you all for the interesting ideas. I must just say that they look kinda workaround-ish don't they?
    I think I'll give a try to Taqua's solution, for the simple reason that this way I can have not only a single xaction but also a single prpt file, which makes a lot of sense in my context.

  6. #6
    Join Date
    Apr 2010
    Posts
    127

    Default

    Update.
    It seems there's a "little" problem: if I set conditional visibility for the subreport (even if it's a constant, e.g. =2>1), all graphs and formulas (totals) included therein do not show up, even explicitly setting them as visible (not inherited). Labels and fields display correctly, but graphs and functions do not.
    If I set the subreport as visible it works correctly, but of course this defeats the purpose.
    Am I missing something here...

  7. #7
    Join Date
    Apr 2010
    Posts
    127

    Default

    Update again.

    I got it working, doing something very weird.
    I had to place each report inside a band, and set visibility on bands (instead of subreports). Also, one band must be placed in the report header, the other in the report footer (if both were in the header, graphs would show but functions would not).
    No idea what's the logic behind this.

    Additionally, since both subreport queries are run (regardless of their visibility), I defined them as
    =IF(condition;"SELECT 0";"first real query")
    and
    =IF(NOT(condition);"SELECT 0";"second real query")
    Last edited by SCP; 05-18-2010 at 05:13 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
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.