Creating filters

To provide flexibility and convenience to end users playing with ad hoc reports, JReport provides two options to narrow down the records:

Defining and applying built-in filters

The following example shows the usage of built-in filters:

  1. In the SampleReports catalog, create a business cube called CustomersCube with the Customers table.

    Next, we will create a built-in filter Country='USA' in the business cube.

  2. In the Business Cube Editor window, click the Filter button on the toolbar to display the Filter dialog. See the dialog.
  3. Click behind the field text box. In the Cube Element Resources dialog, select Country and click OK.
  4. Select = from the operator drop-down list.
  5. Click next to the value text box. In the Values dialog, click the Value sub tab, double-click USA and it will be added to the value box, then close the dialog.
  6. Click OK to save the filter. The filter is used as a built-in filter in the CustomersCube business cube.
  7. Click File > Catalog Management > Save Catalog to save the catalog.
  8. Publish the catalog to JReport Server.
  9. Create reports in Page Report Studio based on the business cube, the filter will be automatically applied to the business cube, that is to say, the report will get data from USA only.

Defining and applying predefined filters

You can also predefine some filters in business/report cubes for ad hoc users to choose when designing/modifying a live report. Let's use the following example to show the basic usage. Note that our example is based on a business cube, the same steps are applied to report cubes as well.

  1. Create a business cube called CustomersOrdersCube with the Customers and Orders tables.
  2. In the Business Cube Editor window, click the Predefined Filter button on the toolbar to display the Predefined Filter dialog. See the dialog.
  3. Click the New button, double-click in the Name cell of the filter and change its name to CustomersFilter, then in the Condition panel, click the Add Condition button and define the filter as Customer ID>=25.
  4. Click the New button to add another filter and name it OrdersFilter, then define the filter as Shopping Cost=150.
  5. Click OK in the Predefined Filter dialog to save the filters.
  6. Save the catalog and publish it to JReport Server.
  7. Create reports based on the business cube in Page Report Studio, and you can choose which filter you want to apply.

For detailed explanations about how to use the predefined filters in Page Report Studio, refer to Applying filters to business/report cubes in the JReport Server User's Guide.

See also Filter dialog and Predefined Filter dialog for additional information about options in the dialogs.

Note: When the resources that are used in some predefined filters are removed from the business cube, the next time when you open the Predefined Filter dialog, you will be prompted with warning messages showing the details and the filters will be removed automatically from the dialog as well.