Creating filters
To provide flexibility and convenience to end users playing with ad hoc reports, JReport provides two options to narrow down the records:
- Built-in filter: It is defined in JReport Designer for business cubes only and transparent to the end users running the business cube reports.
- Predefined filter: It is predefined on the Designer side for both business and report cubes. Ad hoc end users can choose to apply such filter when designing/modifying reports based on the business/report cube.
Defining and applying built-in filters
The following example shows the usage of built-in filters:
- 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.
- In the Business Cube Editor window, click the Filter button on the toolbar to display the Filter dialog. See the dialog.
- Click behind the field text box. In the Cube Element Resources dialog, select Country and click OK.
- Select = from the operator drop-down list.
- 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.
- Click OK to save the filter. The filter is used as a built-in filter in the CustomersCube business cube.
- Click File > Catalog Management > Save Catalog to save the catalog.
- Publish the catalog to JReport Server.
- 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.
- Create a business cube called CustomersOrdersCube with the Customers and Orders tables.
- In the Business Cube Editor window, click the Predefined Filter button on the toolbar to display the Predefined Filter dialog. See the dialog.
- 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.
- Click the New button to add another filter and name it OrdersFilter, then define the filter as Shopping Cost=150.
- Click OK in the Predefined Filter dialog to save the filters.
- Save the catalog and publish it to JReport Server.
- 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.