Applying filters
You can apply filters to business/report cubes and data components such as banded objects, tables, crosstabs and charts of a page report so as to narrow down the data displayed in the page report.
Applying filters to business/report cubes
When creating reports in Page Report Studio, you can choose to apply some filter to the specified business/report cube to narrow down the data scope of the business/report cube. Filters for business/report cubes are defined into two categories in Page Report Studio: predefined filters and user defined filters. As the name suggests, predefined filters are defined on business/report cubes in advance in JReport Designer, and user defined filters are created on business/report cubes while they are used in Page Report Studio.
Filters can be applied to business/report cubes in Page Report Studio in the following ways:
Applying a filter to a business/report cube while creating a report
- In a Page Report Studio window, click Menu > File > New Page Report to display the New Page Report dialog.
- Specify the title of the report as required in the Report Title text box.
- In the Choose Report Layout box, select the layout as Banded, Crosstab, Table or Chart and then click OK.
- In the corresponding report wizard, select the required business/report cube for the report, and the fields you want to display in the report.
- Click the Query Filter screen.
All the predefined filters of the selected business/report cube are listed in the Query Filter drop-down list. Choose the one you want to apply. If you want to further edit the filter, click the Edit button and then redefine the filter as required. The edited filter will then be saved as a user defined filter to the business/report cube.
If you prefer to define a filter on your own, select User Defined from the Query Filter drop-down list, then define the filter according to your requirements.
There are the basic and advanced modes of the screen for you to define either simple or complex filter expressions.
- To define a filter using simple expressions:
- Make sure the dialog is in the basic mode.
- From the field drop-down list, select the field on which the filter will be based.
- From the operator drop-down list, set the operator with which to compose the filter expression.
- Type the values of how to filter the field in the value text box, or select one or more values from the drop-down list.
- If you want to add another condition line, from the logic operator drop-down list,
- To add a condition line of the AND relationship with the current line, select AND, then define the expression as required.
- To add a condition line of the OR relationship with the current line, select OR, then define the expression as required.
Repeat this to add more filter expressions if required. To delete a condition line, click on its left.
- To define a filter using complex expressions:
- Switch the dialog to the advanced mode.
- Click the Add Condition button to add a condition line.
- From the field drop-down list, select the field on which the filter will be based.
- From the operator drop-down list, set the operator with which to compose the filter expression.
- Type the values of how to filter the field in the value text box, or select one or more values from the drop-down list.
- To add another condition line, click the Add Condition button and define the expression as required. Then, click the logic button until you get the required logic to specify the relationship between the two filter expressions. The logic can be AND, OR, AND NOT, or OR NOT.
- Repeat the above steps to add more filter expressions if necessary.
To group some conditions, select them and click the Group button, then the selected conditions will be added in one group and work as one line of filter expression. Conditions and groups together can be further grouped. To take any condition or group in a group out, select it and click Ungroup. It is the equivalent of adding parenthesis in a logic expression.
To adjust the priority of a condition line or a group, select it and click the Up or Down button.
To delete a condition line or a group, select it and click the Delete button.
- Click Finish in the report wizard and the specified filter will be applied to the business/report cube, so that your report will get data that meets the filter condition only.
Applying a filter to a business/report cube while inserting a data component
- In a Page Report Studio window, do either of the following:
- Click Menu > Insert > Banded Object/Table/Crosstab/Chart, point to the destination, and then click the mouse button.
- Drag Banded Object, Table, Crosstab, or Chart from the Toolbox panel to the destination.
- In the corresponding report wizard, select the required business/report cube for the component, and the fields you want to display in the component.
- In the Query Filter screen, specify the filter you want to apply to the business/report cube from the Query Filter drop-down list, or define a filter according to your requirement.
- Click Finish to create the component and the specified filter will be applied to the business/report cube.
Applying a filter to a business/report cube after a report is built
- Select the component in a report which was created on a business/report cube by clicking anywhere in it, and then clicking the icon at the upper left corner of the component.
- Click Menu > Report > Query Filter, or right-click the component and select Query Filter from the shortcut menu to display the Query Filter dialog.
- From the Query Filter drop-down list, select the filter you want to apply to the business/report cube used by the component, or define a filter according to your requirement.
- Click OK to apply the filter to the business/report cube.
Notes:
- A JReport Live license for JReport Server is required in order to use this feature. If you do not have a Live license please contact your Jinfonet Software account manager to obtain a license.
- Business/report cube filters are defined on the component level in Page Report Studio, which means each time you create a component, you can apply a filter to the business/report cube it applies to and it will not affect other components based on the same business/report cube.
- In Page Report Studio, you cannot edit the predefined filters that have been created on a business/report cube at the Designer side. You can just edit the condition based on a predefined filter and then the edited filter will be saved as a user defined filter.
Filtering the data components in a report
There are the following ways you can take in order to filter the data components in a page report: using the Filter dialog, using filter controls, using the shortcut menu, and using labels.
Using the Filter dialog
To set the filtering conditions using the Filter dialog:
- Click Menu > Report > Filter, or the Filter button on the Analysis toolbar to show the Filter dialog. See the dialog.
- Select the component on which the filtering will be based from the Apply to drop-down list.
- Define the filter as required. There are the basic and advanced modes of the dialog for you to define either simple or complex filter expressions.
- Click OK to make the filter take effect and return to the report.
Using filter controls
A filter control is a web control used to filter one or more data components, which refer to tables, banded objects, charts, and crosstabs, in a report using the same data source. A filter control can do filtering based on one field. For details, see Using filter control to filter report data.
Using the shortcut menu
You can also use filter-related commands on the shortcut menu to filter the data in a banded object or table. To do this, point to any value of the field other than the group by field, by which you want to filter data, then right-click to show the shortcut menu. You will see the Filter item which provides a submenu containing the following commands:
- Remove Filter
This command is enabled after you have applied filtering on the field to the banded object or table. Clicking this item will remove all filters on this field.
- Top N
Shows the Top N dialog with which you can filter data to display records that meet the Top N condition.
For example, if you input 3 in the Top N dialog for a certain field, then only the records with the field value equal to one of the first three field values will be displayed.
- Bottom N
Shows the Bottom N dialog with which you can filter data to display records that meet the Bottom N condition.
For example, if you input 3 in the Bottom N dialog for a certain field, then only the records with the field value equal to one of the last three field values will be displayed.
- Field values
"Field values" is not the name for a command on the Filter submenu, but represents some items which are the values of the field you have right-clicked. Selecting any field value listed here will make the banded object or table only display records with the field value equal to the selected one.
- More
This command is enabled if the Filter submenu cannot list all field values. When it is enabled, clicking it will show the Select Values dialog. You can select one value in this dialog and apply the setting, after which the banded object or table will only display records with the field value equal to that value.
Using labels
You can also use a label to control the filter condition in a banded object or table. This feature needs to be enabled at report design time.
- In JReport Designer, select a label in a banded object/table, and then set its Filterable property to true.
- Set the field by which you want to filter records as the value of the label's Bind Column property.
- Save the report and publish it to JReport Server.
- Run the report in Page Report Studio, and you can find that a button is beside the label. Click it to show the Filter list, which contains All, Top N, Bottom N, Custom Filter, the field values, and More (if there are too many distinct values for the field), then click the corresponding item to filter the records.
After applying a filter on the field decided by the Bind Column property, the button will be affixed with a check mark, and you can still click it to show the Filter list, in which the All item can help you remove the filters on the field.
Notes:
- You can also filter records by using the shortcut menu for a label in the same way as for a field value, provided you have set its Bind Column property value to a field.
- When using the shortcut menu for a field value or label to filter, all the items (Remove Filter, Top N, Bottom N, and More) will be showed by default. If you want to disable some of the items, you should set the field's Filter Options property when designing the report in JReport Designer. For details, see Setting filter options for a field in the JReport Designer User's Guide.
- For filtering the data using shortcut menu or labels, you may notice that the corresponding filter expressions will appear in the Filter dialog if you open this dialog.
- JReport allows you to define the display names for fields to be shown in the Filter dialog. For detailed information, see Customizing the field display names in the JReport Designer User's Guide.