Filter Reports
To get specific results on the fly, you can filter reports through the API.
Changes to filters that are made through the API don’t affect the source report definition. Using the API, you can filter with up to 20 custom field filters and add filter logic (such as AND and OR). But standard filters (such as range), filtering by row limit, and cross filters are unavailable.
Before you filter a report, it’s helpful to check the following filter values in the metadata.
- The
ReportTypeColumn.getFilterablemethod tells you whether a field can be filtered. - The
ReportTypeColumn.filterValuesmethod returns all filter values for a field. - The
ReportManager.dataTypeFilterOperatorMapmethod lists the field data types that you can use to filter the report. - The
ReportMetadata.getReportFiltersmethod lists all filters that exist in the report.
You can filter reports during synchronous or asynchronous report runs.
To filter a report, set filter values in the report metadata and then run the report. The following example retrieves the report metadata, overrides the filter value, and runs the report. The example:
- Retrieves the report filter object from the metadata by using the
ReportMetadata.getReportFiltersmethod. - Sets the value in the filter to a specific date by using the
ReportFilter.setValuemethod and runs the report. - Overrides the filter value to a different date and runs the report again.
The output for the example shows the differing grand total values, based on the date filter that was applied.