Jump to content
We've recently updated our Privacy Statement, available here ×
  • 'Filter' Data of Crosstabs Based On The Same Dataset


    asimkin
    • Features: Reports Version: v7.1 Product: JasperReports® Library

    Use Case

    User developed a JRXML report with 2 Crosstab elements ponting to the same main dataset.

    Now, the user has a requirement 'to filter' the data for each Crosstab, so that Crosstab1 displays data for a specific column value, while the second Crosstab2 - for another value.

    Using SubDataset for the second Crosstab is not an option for the user.


    Resolution

    A possible solution to achieve the requirement is to specify 'Increment When Expression' property for each Crosstab Dataset.

    The 'Increment When Expression' is a flag to determine whether to add a record to the record set that feeds the Crosstab.

    This expression must return a Boolean value. A blank string means to 'add all the records':

    crosstab_incrementexpression.png.2f8d2a0ae169f968ede293086743ce28.png

    Attached is a sample report based on SugarCRM database, Orders table, which demonstrates the idea

    The main report query returns records for all countries (shipcountry field):

    SELECT * FROM orders LIMIT 1000
    

     

    Setting 'Increment When Expression' to value

    $F{shipcountry}.equals("USA")[/code]

    processes records with USA country only for the first Crosstab.

    Setting 'Increment When Expression' to value

    $F{shipcountry}.equals("Canada")[/code]

    processes records with Canada country only for the second Crosstab.

    report_output_0.png.5f612fc152c3c804c0429bac8b79eb8b.png

    Solution tested with  TIBCO JasperReports® 7.1.0.


    AS-20190405, case #01736277


    support_crosstabfilters_solution.jrxml


    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...