Filter Reports on Demand

To get specific results on the fly, filter reports through the API. Filter changes made through the API does not 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, 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 these properties in the metadata that tell you if a field can be filtered, the values and criteria you can filter by, and filters that already exist in the report.

  • filterable
  • filterValues
  • dataTypeFilterOperatorMap
  • reportFilters

You can filter reports during synchronous or asynchronous report runs by making a POST request to the Execute Sync or Execute Async resource.

Example 

In a POST request, an accounts report is filtered synchronously by these passing filters with filter logic in the metadata to the Execute Sync resource.

  1. Account Name not equal to Data Mart
  2. Account Owner not equal to Admin User
  3. Annual Revenue greater than “100,000”
  4. Industry not equal to Manufacturing,Recreation

Filter logic: (1 OR 4) AND 2 AND 3.

1{
2    "reportMetadata": {
3        "name": "FilterAcctsReport",
4        "id": "00OD0000001cw27MAA",
5        "reportFormat": "SUMMARY",
6        "reportBooleanFilter": "(1OR4)AND2AND3",
7        "reportFilters": [
8            {
9                "value": "DataMart",
10                "operator": "notEqual",
11                "column": "ACCOUNT.NAME"
12            },
13            {
14                "value": "AdminUser",
15                "operator": "notEqual",
16                "column": "USERS.NAME"
17            },
18            {
19                "value": "\"100,000\"",
20                "operator": "greaterThan",
21                "column": "SALES"
22            },
23            {
24                "value": "Manufacturing,Recreation",
25                "operator": "notEqual",
26                "column": "INDUSTRY"
27            }
28        ],
29        "detailColumns": [
30            "RATING",
31            "LAST_UPDATE",
32            "SALES"
33        ],
34        "developerName": "Filter_Accts_Report",
35        "reportType": {
36            "type": "AccountList",
37            "label": "Accounts"
38        },
39        "currency": null,
40        "aggregates": [
41            "s!SALES",
42            "RowCount"
43        ],
44        "groupingsDown": [
45            {
46                "name": "USERS.NAME",
47                "sortAggregate": "s!SALES",
48                "sortOrder": "Desc",
49                "dateGranularity": "None"
50            },
51            {
52                "name": "ACCOUNT.NAME",
53                "sortAggregate": null,
54                "sortOrder": "Asc",
55                "dateGranularity": "None"
56            },
57            {
58                "name": "DUE_DATE",
59                "sortAggregate": null,
60                "sortOrder": "Asc",
61                "dateGranularity": "Month"
62            }
63        ],
64        "groupingsAcross": []
65    }
66}

In response to the POST request, the report returns data that meets the given criteria.

1{
2    "hasDetailRows": false,
3    "attributes": {
4        "describeUrl": "/services/data/v29.0/analytics/reports/00OD0000001cw27MAA/describe",
5        "instancesUrl": "/services/data/v29.0/analytics/reports/00OD0000001cw27MAA/instances",
6        "type": "Report",
7        "reportName": "Filter Accts Report",
8        "reportId": "00OD0000001cw27MAA"
9    },
10    "factMap": {
11        "1_0!T": {
12            "aggregates": [
13                {
14                    "value": 56000000,
15                    "label": "$56,000,000"
16                },
17                {
18                    "value": 1,
19                    "label": "1"
20                }
21            ]
22        },
23        "7_1!T": {
24            "aggregates": [
25                {
26                    "value": 24000000,
27                    "label": "$24,000,000"
28                },
29                {
30                    "value": 1,
31                    "label": "1"
32                }
33            ]
34        },
35...
36    "allData": true,
37    "reportMetadata": {
38        "name": "Filter Accts Report",
39        "id": "00OD0000001cw27MAA",
40        "reportFormat": "SUMMARY",
41        "reportBooleanFilter": "(1 OR 4) AND 2 AND 3",
42        "reportFilters": [
43            {
44                "value": "Data Mart",
45                "operator": "notEqual",
46                "column": "ACCOUNT.NAME"
47            },
48            {
49                "value": "Admin User",
50                "operator": "notEqual",
51                "column": "USERS.NAME"
52            },
53            {
54                "value": "\"100,000\"",
55                "operator": "greaterThan",
56                "column": "SALES"
57            },
58            {
59                "value": "Manufacturing,Recreation",
60                "operator": "notEqual",
61                "column": "INDUSTRY"
62            }
63        ],
64        "detailColumns": [
65            "RATING",
66            "LAST_UPDATE",
67            "SALES"
68        ],
69...
70    }
71}

See Also