Sub topic 6
Adding dashboard filters
This chapter assumes you can build a summary report and a dashboard with several components, as covered in the earlier chapters. It also assumes you know what a running user is. Here you will add filters so viewers can narrow a dashboard without editing it.
What a dashboard filter does
A dashboard filter is a control at the top of a dashboard. It applies one extra condition to every component that can use it. A sales manager can pick "New Customer" and see every chart, gauge, metric and table restricted to new-customer opportunities.
Without filters, you would need one dashboard per segment, such as region, product line or account type. Filters let one dashboard serve all of them. You maintain one set of components, and viewers choose the slice.
A filter is not a new data source. It adds a condition to the existing source reports. If a component's source report already has a filter, the dashboard filter is combined with it, and a record must satisfy both.
How filters combine with other conditions
A record appears in a filtered component only if it passes every layer:
- The running user can see the record (sharing, role hierarchy, and the dashboard's running user setting).
- The record matches the source report's own filters.
- The record matches the dashboard filter value the viewer selected.
A dashboard filter can only narrow results. It cannot reveal records that the running user cannot see, and it cannot bring back records the source report has already excluded. If a viewer selects a value and the component goes empty, one of the earlier layers is usually the cause.
The SOQL below shows the effect for an open-pipeline summary report. The first query is the unfiltered component. The second is what the component effectively returns when the viewer picks Type = New Customer.
SELECT StageName, SUM(Amount) total
FROM Opportunity
WHERE IsClosed = false
GROUP BY StageNameSELECT StageName, SUM(Amount) total
FROM Opportunity
WHERE IsClosed = false
AND Type = 'New Customer'
GROUP BY StageNameSalesforce does not run SOQL for dashboards. The queries only illustrate the added AND condition.
Adding a filter in the dashboard editor
You add filters in the dashboard editor, not on the viewing page. The steps in Lightning Experience are:
- Open the dashboard and choose Edit.
- Select Add Filter (the filter button at the top of the editor).
- Choose the field to filter on. The list shows fields that exist in the source reports.
- Give the filter a display name that viewers will recognize.
- Add filter values. Each value has an operator (for example equals, not equal to, contains, greater than) and a value.
- Save the filter, then save the dashboard.
Viewers then see the filter at the top of the dashboard. They pick one of the values you defined and apply it.
Choosing the field
The field you pick must be available to the reports behind the components. If two components use different report types, such as Opportunities and Cases, a field like Account Name may exist in both and filter both. A field like Stage exists only on opportunity reports, so it filters only those components.
When the field is not present in a component's report, that component is not filtered. It keeps showing unfiltered data. This is the most common source of confusion with filters, because a dashboard can look partly filtered.
Defining filter values
Filter values are choices you define in advance. Viewers pick from your list. They cannot type in arbitrary values.
- You can give each value a label, so the viewer sees "Enterprise" instead of a raw condition.
- A value can use any operator the field type supports. A numeric field can offer "less than 10,000" and "10,000 or more" as separate choices.
- A single filter value can combine several raw values, such as one entry that matches several stages.
- Limits apply to the number of values per filter. Check the current Salesforce limits for your edition before designing a filter with a long list.
Because the list is fixed, a new picklist value added later does not appear in the filter automatically. Someone has to edit the dashboard and add it.
Limits to design around
| Item | Behavior |
|---|---|
| Filters per dashboard | A small fixed maximum (three at the time of writing). Check the current limit. |
| Values per filter | Capped. Plan a short, meaningful list. |
| Components without the field | Not filtered. They show all data. |
| Filter choices | Only the values defined by the dashboard builder. |
| Joined reports | Not supported as dashboard sources, so they cannot take part in filtering. |
The filter count is the tightest constraint. With only a few filters, choose fields that cut across most components, such as owner, region, product family or date range. Avoid spending a filter on a field only one component uses.
Choosing good filter fields
Good filter fields share three properties:
- They exist in most of the source reports.
- They have a small number of meaningful values.
- Viewers ask for them often.
A field with hundreds of values, such as account name, makes a poor filter because you cannot list them all. A field that appears in only one report leaves the rest of the dashboard unchanged.
For consistent filtering, build the source reports from the same report type where you can. Reports built on the same report type share the same fields, so one filter reaches every component. Mixing report types is allowed, but you must verify each component after adding the filter.
Filters and the running user
Filters never widen visibility. A static dashboard runs as one named user, so a filter narrows what that user can see. A dynamic dashboard runs as the viewer, so a filter narrows what the viewer can see.
This has a practical consequence for dynamic dashboards. Do not add an "Owner" filter expecting it to let a rep see a colleague's records. The rep's own visibility is the ceiling, and the filter only reduces it. With a static running user such as a sales director, an owner filter is useful, because the dashboard can see everyone's records and the filter picks one person's.
Testing a filter
After you save, check each component before you share the dashboard.
- Open the dashboard and apply each filter value in turn.
- For each component, confirm the numbers change. A component that stays the same does not contain the filter field.
- Compare one component against its source report. Open the report, add the same condition, and confirm the totals match.
- Apply a value that should return nothing and confirm the component shows an empty state, not an error.
- Check the dashboard as a user with a different profile, or use View Dashboard As if your permissions allow it, so you see what actual viewers see.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| One component ignores the filter | Its report does not contain the filter field | Rebuild the report on a report type that includes the field |
| Every component is empty after filtering | The value does not match any visible records, or the operator is wrong | Test the same condition in the source report |
| Filter list is missing a new picklist value | Filter values are fixed when defined | Edit the dashboard and add the value |
| Cannot add another filter | The per-dashboard maximum is reached | Remove or combine filters, or split the dashboard |
| Totals differ from the report | The report has its own filters that also apply | Compare both sets of conditions together |
Summary of the working model
- A dashboard filter adds one condition on top of the running user's visibility and the report's own filters.
- It affects only components whose source reports contain the chosen field.
- Viewers choose among values you predefine, up to fixed limits.
- It narrows data and never grants access.
- Always test each component after adding a filter.
Exercise
A dashboard has five components. You add a filter on Opportunity Type. Four components change when a viewer selects "New Customer", but a Cases table does not. Why, and what are two ways to fix it?
Show answer
The Cases table's source report does not contain the Opportunity Type field, so the dashboard filter cannot apply to it and it keeps showing all its data. You can fix it by rebuilding or replacing the report with one whose report type includes a field that the filter can use, for example a field common to every component, or by choosing a different filter field that exists in all the source reports. You can also move the Cases table to a separate dashboard if filtering it does not make sense.
Exercise
A dynamic dashboard runs as the logged-in user. A sales rep adds an "Owner" filter and selects a colleague's name. The component shows no data. Is this a bug?
Show answer
No. On a dynamic dashboard the rep's own record visibility is the upper limit, and the filter can only narrow it. If the rep cannot see the colleague's opportunities, the filter returns nothing. To let someone view other users' data, use a static running user with suitable access, such as a manager.