Sub topic 1
Reports: the data behind every dashboard
Prerequisites
This chapter assumes you can navigate Lightning Experience, know the standard objects Accounts, Opportunities and Cases, and can create and run a basic report. It also assumes you know that profiles, roles and sharing rules control which records a user can see.
Why reports come first
A dashboard does not query records on its own. Every dashboard component reads from one source report. The component takes the report's grouped or summarized results and draws them as a chart, gauge, metric or table.
This has three consequences:
- A component can only show what its report returns. If the report has no grouping or summary field, the component has nothing to plot.
- Changing the report changes every component built on it.
- Visibility depends on the report's data and on the dashboard's running user. A later chapter covers the running user in detail.
Report formats and what dashboards can use
Salesforce has four report formats. They differ in how much they summarize.
| Format | Structure | Usable as a dashboard source |
|---|---|---|
| Tabular | Flat list of rows, like a spreadsheet | Only for tables and metrics, and only with a row limit |
| Summary | Rows grouped by one or more fields | Yes, for all component types |
| Matrix | Rows and columns grouped | Yes, for all component types |
| Joined | Several report blocks side by side | Not for standard dashboard components |
Summary and matrix reports are the best sources, because their groupings supply the categories that charts need. The next chapter covers how to prepare them.
The parts of a report that matter
Four parts of a report shape the dashboard that uses it:
- Report type. This sets the objects and relationships you can report on, such as Opportunities with Products. You can't change which objects are available once you have built on a type, so choose it first.
- Filters. They limit the records. Examples are a date range, an open-only setting (
IsClosed = false), or a scope such as "My opportunities". - Groupings. These are the fields that rows are grouped by, such as Stage or Owner. A chart's categories come from them.
- Summaries. These are the numbers calculated per group, such as a record count, a sum of Amount or an average.
A report and its SOQL equivalent
The report "Open pipeline by Stage" filters to open opportunities, groups by Stage and sums Amount. Its logic is the same as this SOQL query:
SELECT StageName, SUM(Amount) total
FROM Opportunity
WHERE IsClosed = false
GROUP BY StageNameThe WHERE clause matches the report filters. GROUP BY matches the grouping. SUM(Amount) matches the summary. A chart component built on that report would show one bar per stage, with the bar's height set by the total.
The report does not run as raw SOQL, and the query ignores record sharing. A report respects the sharing of the user whose view it takes, so two people can see different totals from the same report.
Common mistakes
- Using a tabular report with many rows. Dashboards show a limited number of rows from it, so results look cut off.
- Leaving the date filter too broad. A report that spans all time loads slowly and hides trends.
- Editing a shared report without checking its dashboards. A changed grouping or filter can leave a component empty or wrong.
- Storing the report where viewers can't open it. The dashboard viewer may see data but get an access error when drilling into the report.
Exercise
A teammate builds a dashboard chart from a tabular report and finds that the chart has no categories to display. What is the likely cause, and what is the fix?
Show answer
A tabular report has no groupings, so a chart has nothing to use as categories. Change the report to a summary report and group it by a field such as Stage or Owner, then point the chart at it.
Exercise
Which two parts of the report "Open pipeline by Stage" correspond to the SOQL WHERE IsClosed = false and GROUP BY StageName clauses?
Show answer
The filter for open opportunities matches WHERE IsClosed = false, and the grouping by Stage matches GROUP BY StageName.