Skip to content

Sales pipeline and forecast

At a glance

Company: Halden Equipment Co., a B2B seller of warehouse and material-handling equipment with 10 reps on two sales teams
Problem: The quarterly forecast was a guess, and stalled deals stayed on it for months
Deliverable: A weekly pipeline from CRM data into Postgres, a win model that is monitored and retrained automatically, and a five-page Power BI report
Role: Sole builder, from the data through the model and the report
Code: GitHub repository

About this case study

I built this case study to show how I work from start to finish. Halden Equipment is a fictional company. The CRM data is simulated, with realistic patterns built in on purpose: reps who over-commit, deals that stall, a shift in lead quality. The system runs live: every Monday a new week of data is simulated, loaded, scored and checked, the same way it would run for a client.

Forecast page of the Halden Power BI report

The Forecast page, where the report opens: the model's call for the quarter, its range, the chance of hitting quota, and how each forecasting method has moved week by week.

Challenge

Halden sells forklift fleets, conveyor lines and racking to warehouses and distributors, bought or leased. Every Monday the head of sales has to answer two questions for the forecast call: will we hit the quarter, and which deals need attention?

The answers on hand didn't agree, and none could be checked:

  • The CRM forecast multiplied each deal by a fixed stage probability that nobody had revisited in years.
  • Rep commits swung with each rep's habits. Some reps always committed high, others always low.
  • Stalled deals stayed in the forecast by having their close dates pushed, sometimes dozens of times.
  • Nobody knew how accurate any of these forecasts had been in past quarters.

Approach

  • Snapshot the pipeline every week. CRM data (deals, stage history, activities, rep commits, quotas) loads into Postgres every week, and dbt rebuilds a snapshot of every open deal as it stood that week. That snapshot history is what makes an honest model possible: it only ever learns from what was known at the time.
  • Score every deal, not just the quarter. A machine learning model gives each open deal three chances: won this quarter, won later, or lost. A simulation then plays the quarter out 10,000 times from those scores to produce a realistic range, not a single number. Each score comes with its top three reasons in plain words, such as "278 days in Negotiation".
  • Prove the forecast before asking anyone to trust it. Every forecasting method, including the model, the CRM's stage probabilities and the reps' commits, is graded against what each past quarter actually closed, at the same week of the quarter.
  • Keep the model honest over time. Every Monday the system checks whether the incoming data has drifted and whether accuracy is slipping. It retrains automatically every four weeks, or sooner when both checks fire, and a new model only goes live if it beats the current one.
  • Build the report around the Monday meeting. Each page answers one question a sales leader asks every week. Every number can be moved back to any past week and shows exactly what was known then.

Architecture

CRM data, weekly Postgres (Neon) dbt weekly snapshots Win model Drift checks, retraining Power BI report

Prefect runs the whole chain every Monday morning on free cloud machines: load the new week, build and test the models, score every open deal, check for drift, and retrain when due.

What the report surfaced

The CRM said the quarter was safe. The model disagreed.

At week 8 of the quarter, the CRM's stage-weighted forecast sat around $10.8M, about 21% above the $8.91M quota. The model said $8.55M, 4% short, with a 38% chance of hitting quota. Its call had been sliding for two weeks, while the CRM's had climbed for most of the quarter.

The model has the better record. Across every finished quarter, measured at the same point in the quarter, the CRM method missed the final number by 21.6% on average. The model missed by 10.2%, the best of the four methods tracked. The reps' commit came close at 10.8%, but the model gets there without waiting on reps and adds a range and the reasons behind each deal.

$23M scheduled to close, $3.9M expected

Deal risk page

Reps had $23.4M of deals scheduled to close this quarter. The model expected $3.9M of it. Most of the gap is early-stage deals with optimistic close dates. The rest is a review list: 127 late-stage deals worth $7.5M that the model gives under a 36% chance, each with its six-week trend and the main reason it is low. Almost half the scheduled pipeline also had at least one CRM problem, most often deals stuck in their stage.

More pipeline, worse pipeline

Conversion page

New pipeline was up 54% on the usual pace, which looks like good news on its own. The rest of the page shows the cost: the win rate fell 5 points and losses nearly doubled. Paid social brought 36% of new deals with an 11% win rate, against 26% to 39% for every other source. At the other end of the funnel, Negotiation was converting 10 points below normal, and "chose a competitor" was the fastest-rising loss reason.

The model checks itself every week

Accuracy page

The Accuracy page answers "can we trust it?" with evidence:

  • Each method's error by week of the quarter.
  • Whether the model's percentages mean what they say: deals it scored between 10% and 20% won 15% of the time, exactly as scored, and it is slightly cautious on its most likely deals.
  • The two health checks that trigger a retrain.
  • Each rep's commit bias. One rep has committed 90% more than he closed; two others consistently under-commit.

Every deal explains itself

Deal detail drill-through page

Any deal drills through to its own page: its win chance week by week, the model's three biggest factors, CRM red flags and its latest activity. This one, the largest deal on the review list, has sat in Negotiation for 278 days with its close date pushed 29 times, and the last real activity was three months earlier. The model had marked it down long before. A manager can now ask the right question in a 1:1: is this deal still real?

Before and after

Before After
Quarter forecast CRM stage probabilities and rep commits that disagreed One forecast with a range, a chance of hitting quota and a track record
Trust in the number Unknown; nobody checked past forecasts Every method graded against past quarters at the same week
Deal reviews The biggest deals, or whoever was loudest A ranked list of at-risk deals, each with its trend and the main reason
Stalled deals Kept alive by pushing the close date Flagged by rule and by the model, with full history one click away
Rep commits Taken at face value Each rep's commit bias measured against what they actually closed

Cost to run

The whole stack runs on free tiers: Neon for Postgres, Prefect Cloud for the weekly schedule, Backblaze B2 for stored model files, and the free Power BI Desktop. The only paid piece is Power BI Pro, about $14 per user per month, and only for people who view the report in the Power BI Service. There is no data warehouse or machine learning platform to pay for.

What's next

  • A live HubSpot connection in place of the simulated data (the loading code already follows HubSpot's structure)
  • Writing each week's deal scores back into the CRM automatically, so reps see them where they work
  • Publishing to the Power BI Service with a refresh scheduled right after each weekly run

Code

The simulator, data pipeline, dbt models, machine learning code and the Power BI project are on GitHub: almagall/halden-sales-forecast.

Tech stack

  • Python, dbt and PostgreSQL (Neon)
  • scikit-learn and LightGBM (win model), SHAP (reasons for each score)
  • MLflow (model tracking), Evidently (drift monitoring), Prefect (weekly orchestration)
  • Power BI (DAX, point-in-time model, drill-through), built as a PBIP project
  • Not sure your sales forecast is telling you the truth?


    Book a free 30-minute intro call. Tell me how you forecast today and what you'd want to know earlier, and I will tell you honestly whether I can help and what it would take.

    Book a free intro call