Sub topic 3
Filtering and scoping report data
This chapter assumes you can open the report builder in Lightning Experience and that you know how Account and Opportunity relate. Filters decide which records enter a report. Groupings and summaries only work on the records that survive them.
Where filters fit
Every report starts with a report type, which defines the pool of records. Filters shrink that pool. Totals, averages, and record counts are then calculated from the remaining rows.
Scope: whose records
The scope setting, labeled Show Me, limits records by ownership or team. Typical values are All, My, and My team's. The choices depend on the object. A scope never gives you access to records you could not already see. Sharing rules and permissions still apply, so two users can run the same report and get different totals.
Date range filters
A date range filter has two parts: a date field and a range. For Opportunities, the field is usually Close Date. The range can be fixed, such as 1 Jan to 31 Mar, or relative, such as Current FQ or Last 30 Days. Prefer relative ranges for recurring reports, because they update themselves.
Field filters and filter logic
A field filter has a field, an operator, and a value. Examples are Stage equals Closed Won, or Amount greater than 10000. By default, all filters are combined with AND. Custom filter logic lets you mix AND and OR by referring to the filter numbers:
1 AND (2 OR 3)Here, filter 1 must always be true, and either filter 2 or filter 3 must be true. Every filter number must appear in the expression. Parentheses decide how conditions group, so check them when the totals look wrong.
Cross filters
A cross filter keeps or removes records based on related records. For example, show Accounts with Opportunities, or Accounts without Cases. You can add conditions on the related object, such as Opportunities with Amount over 50000. Use cross filters when the question is about existence ("which accounts have no open cases?"). A field filter cannot answer that kind of question.
The same idea in SOQL
Filters correspond to the WHERE clause of a SOQL query. This query returns the open opportunities for the current fiscal quarter, grouped by stage:
SELECT StageName, SUM(Amount) total, COUNT(Id) cnt
FROM Opportunity
WHERE CloseDate = THIS_FISCAL_QUARTER AND IsClosed = false
GROUP BY StageNameCommon errors
- Unexpected totals: a default date filter or scope is still applied. Open the filter panel and read every row.
- Missing records: the report type excludes them, or sharing hides them. A report type that requires related records drops parents that have none.
- Wrong logic: OR conditions that are not wrapped in parentheses change the meaning of the whole expression.
- Stale ranges: a fixed date range keeps running long after the period it was written for.
Exercise
A report on Opportunities uses these filters: 1) Stage equals Closed Won, 2) Amount greater than 50000, 3) Type equals New Business. You want closed-won deals that are either over 50000 or New Business. What filter logic do you enter?
Show answer
1 AND (2 OR 3). Filter 1 is required, and the parentheses make filters 2 and 3 alternatives. Without them, the logic would not match the requirement.
Exercise
A colleague runs your report with the scope My team's. Her totals are lower than yours, although the filters are identical. Name one likely reason.
Show answer
Sharing and permissions limit which records she can see, and her team's records may differ from the ones included in your run. Scope never overrides access.