Jump to content
We've recently updated our Privacy Statement, available here ×
  • Customer Demo: How to create a Multi Select Filter in a Report


    emistry
    • Features: Filters Version: v6.0.1 Product: Jaspersoft® Studio

    Create a Blank Report in Jaspersoft Studio and populate with the following SQL:

    SELECT store.store_country,
           store.store_state,
           sales_fact_1998.store_cost,
           sales_fact_1998.store_sales,
           sales_fact_1998.unit_sales
      FROM store
     INNER JOIN sales_fact_1998 ON sales_fact_1998.store_id = store.store_id
     WHERE $X{IN, store.store_country, COUNTRY_P}
    

    Tidy up the report by deleting bands and get the report looking like this:

    1(85).png.3a50b1fcce52eed9655ac65d75ae32a1.png

    Publish the report to the Server, as most of the magic is done there ...

    Edit the Published Report :

    1(88).png.ed5a6df35e8daec0c510a91355757f3e.png

    Select the "Controls & Resources" and change the Display Mode to "In Page" and select the "COUNTRY_P" Input Control

    Go through the Configure Wizard and Select the following options:

    1(91).png.a105a1dd2dbfe185c162498526d0ed80.png
    1(93).png.e3c22b6a1249b555c42b9de6c93bc4f5.png
    1(94).png.88c2abdbfbdefe7e8a0ad70f53f1818e.png
    1(95).png.ae6e1aff58040f0d7b18f4698d0ae54c.png
    1(96).png.21433568f138c1c01c428579d09467bc.png

    1(97).png.cb824804afa0dba89b5c65261aca60e5.png

    Save the Input Parameter

    1(98).png.5ad4c4346049b2fe1d7bf4deba6dbde0.png

    Submit the Input Parameter

    Then select the MultiSelectReport  and you will a Multi Select Query which works as expected:

    1(99).png.b2b6169e32dddf2506e769e36002e6da.png

    CASCADING FILTER - EXTENSION

    As an extension to this WIKI page you can extend quite easily to make it a Cascading Filter Report :

    Use this as SQL in your Studio Report .. 

    SELECT store.store_country,
           store.store_state,
           sales_fact_1998.store_cost,
           sales_fact_1998.store_sales,
           sales_fact_1998.unit_sales
      FROM store
     INNER JOIN sales_fact_1998 ON sales_fact_1998.store_id = store.store_id
     WHERE $X{IN, store.store_country, COUNTRY_P}
       AND $X{IN, store.store_state,   STATE_P  }
    

    Note that I have extended the where clause to add a second condition which will form the second part of the filter.

    Then publish to server as above and add a 2nd Input Control called STATE_P in the same way as above replacing COUNTRY with STATE until you get to the query string. At this point use this query string 

    SELECT store.store_state
      FROM store 
     WHERE $X{IN, store.store_country, COUNTRY_P} 
     ORDER BY store.store_country,store.store_state
    

    The Value and Visible columns should be both 'store_state'.

    This should up a simple cascading filter.

    1(99).png.7e5d2d83d9da5451fa85d9ed0956b408.png

    multiselectreport.jrxml

    cascadingparametersreport.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...