Sub topic 13
Stage history and pipeline reporting
This chapter assumes you can build and run a basic report in Salesforce. It also assumes you know the Opportunity stage picklist, probability, and forecast category from earlier chapters. The SOQL examples are optional. You can run them in the Developer Console Query Editor or in Salesforce Inspector.
By the end you will be able to report on open pipeline by stage and read the stage history of a single deal. You will also know which report type to choose for stage-duration and movement questions, and where these reports usually go wrong.
Two views of the same data
Pipeline reporting answers two different kinds of question.
- Snapshot questions ask what the pipeline looks like right now. How many open deals are in each stage, and what is their total amount?
- History questions ask how deals got there. How long did this deal sit in Proposal? Did the close date slip? When did the amount change?
Snapshot questions read the current values on the Opportunity record. History questions need Salesforce to have recorded earlier values, and that recording works differently for each kind of field.
Pipeline by stage: the snapshot report
The basic pipeline report is a summary report grouped by Stage, with a count of records and a sum of Amount. The SOQL below has the same shape, so it shows what the report does.
SELECT StageName, COUNT(Id) deals, SUM(Amount) total
FROM Opportunity
WHERE IsClosed = false
GROUP BY StageNameThree details in this query matter in the report builder as well.
IsClosed = falsekeeps only open deals. In a report, use the filter Closed = False, or the standard "Open Opportunities" scope. Do not filter on a list of stage names. If someone adds a stage later, a name list silently excludes it, whileIsClosedfollows the stage's Closed setting from the sales process.SUM(Amount)adds raw amounts. A deal with a blank Amount counts as a deal but adds nothing to the total, so the average deal size will look wrong if many records have no amount.- In a multi-currency org, a SOQL sum adds numbers in different currencies together. The report builder converts to your corporate currency by default. If you query with SOQL, use currency conversion explicitly or group by
CurrencyIsoCode.
In the report builder, start from the Opportunities report type. Group rows by Stage, show the Amount and Probability summaries, and add a chart. Also think about the order of stages. A report sorts stage groups alphabetically by default, which scrambles the funnel. The usual fix is to sort by the picklist order where the report offers it, or to put a number in the stage name, such as "2 - Qualification". If you do that, understand the cost: the numbers become part of every integration, filter, and formula that uses the stage name. Renumbering later means touching all of them.
Useful variations
- Add Forecast Category as a second grouping to see how much of each stage is Pipeline, Best Case, or Commit.
- Filter by Close Date (for example "Current FQ") so the report shows deals expected this quarter, not every open deal ever created.
- Use a bucket field to group stages into broader phases such as Early, Mid, and Late without changing the picklist.
- Show Age or Created Date to find old deals that have not moved.
How stage history is recorded
When a user changes certain fields on an opportunity, Salesforce writes a row to a system object called OpportunityHistory. It is read-only. You cannot edit or delete its rows, and you cannot add fields to it.
A new row is created when any of these change:
- Stage
- Amount
- Close Date
- Probability
- Forecast Category
Each row stores the values after the change (and previous Amount and previous Close Date), along with the timestamp. That makes it a record of the deal's stage, amount, and close-date path. It also reports Salesforce's own calculated fields, such as expected revenue.
Here is a query that lists the history of one opportunity in order:
SELECT StageName, Amount, CloseDate, CreatedDate
FROM OpportunityHistory
WHERE OpportunityId = '006XXXXXXXXXXXXXXX'
ORDER BY CreatedDateReplace the placeholder with a real opportunity ID. On the record page, the Opportunity History related list shows the same rows. The lines let you see that a deal moved from Qualification to Proposal on one date and that its amount dropped in the same edit.
Opportunity history exists whether or not an admin turned anything on. That is different from field history tracking, covered next.
Field history tracking: the other source
Field history tracking is a setting an admin turns on per object, and per field, in Object Manager. For Opportunity you can track up to 20 fields. Examples include Owner, Type, Lead Source, and custom fields such as a Competitor picklist. Rows go to a separate history table, and the report type for it is Opportunity Field History.
Be aware of these points:
- Tracking only starts when you enable it. Changes made before that are not recorded, and they cannot be added later.
- Each row holds one field's old and new value, so a single edit that changes three tracked fields creates three rows.
- Tracked history is kept for a limited time, so very old changes may no longer be available. Check the current limits for your edition before promising an audit trail.
- Tracking long text fields only records that the field changed, not the values.
Use OpportunityHistory for stage, amount, and close-date movement. Use field history tracking for everything else you need to audit.
Choosing the report type
| Question | Report type | Notes |
|---|---|---|
| How many open deals are in each stage today? | Opportunities | Current values only |
| How long has each deal been in its current stage? | Opportunities with History | Use the Stage Duration and Last Stage Change Date columns |
| What stages and amounts has a deal passed through? | Opportunities with History | One row per history entry, so totals can double count |
| Who changed the Competitor field, and when? | Opportunity Field History | Only for tracked fields |
| What was my pipeline at the end of last month? | Opportunities with trending (historical trend reporting) | Needs setup, and it is limited to the fields you pick |
Pay attention to the second and third rows. A history report type returns one row per history entry, not one per opportunity. If you sum Amount on it, one deal with six history rows is counted six times. To get one row per deal, filter to the specific change you need, or use the opportunity's own fields.
Time in stage
The standard Stage Duration report is built on Opportunities with History. It shows how many days a deal spent in each stage and is useful for finding bottlenecks. Two edge cases cause confusion:
- If a deal goes back to an earlier stage, its time in that stage is measured per visit, so you can see more than one row for one stage.
- A deal's stage duration only covers time since the history started. Deals imported with a stage already set have no earlier history, so their first row begins at the import date.
Also remember that a change to Amount or Close Date creates a history row too. This can cut a stage's time into several pieces, so check which rows you are summing.
Common errors
- Double counting from history reports. See the table above. Summing Amount on a report with one row per history entry gives inflated totals.
- Filtering on stage names. New or renamed stages drop out of the report. Filter on Closed or Won, or use Forecast Category.
- Treating Amount as stable. Pipeline numbers change when reps edit amounts, so a report run today and a report run next week are not comparable unless you use trend reporting or exported snapshots.
- Assuming history for untracked fields. If nobody enabled field history tracking, the information is gone.
- Editing stages without a migration plan. Renaming a stage value changes the label on current records and in reports. Historical rows keep working because they store the value as it was, but filters written against the old name stop matching. Check saved reports and dashboards after any stage change.
- Ignoring record types. Different sales processes have different stages. A single "by stage" report across record types mixes them, so add Record Type as a grouping.
Putting it together
A practical set of reports for a sales team:
- An open-pipeline summary by Stage and Forecast Category, filtered to the current quarter.
- A stage-duration report grouped by Stage, to see where deals stall.
- A "stale deals" list view of open opportunities where the last stage change is more than 30 days old.
- A dashboard that charts report 1 and shows the others as tables, refreshed on a schedule.
Review it each quarter, and again after any change to stages, so the reports still match the sales process.
Exercise
A manager builds a report on the "Opportunities with History" report type and sums Amount for open deals. The total is three times what the pipeline summary shows. What is the likely cause, and how can it be fixed?
Show answer
The report has one row per history entry, not one per opportunity. A deal whose stage, amount, or close date changed several times appears several times, so its Amount is added each time. Fix it by using the plain Opportunities report type for totals and keeping the history report type for movement and duration questions. Alternatively, filter the history report to the specific change you want, so each deal contributes one row.
Exercise
You need to know who changed an opportunity's Competitor picklist and when, for deals changed last month. Competitor has never been tracked. Can OpportunityHistory answer this?
Show answer
No. OpportunityHistory only records Stage, Amount, Close Date, Probability, and Forecast Category. Competitor needs field history tracking, which only records changes made after it is enabled, so last month's changes cannot be recovered. Enable tracking now for future changes.