xGChain & xGBuildup 101
What each metric measures, which gap they fill (left by xA and xAG), which players have posted the best build-up numbers this season, and how to pull xGChain/xGBuildup data with Python
Hi friend,
Welcome to The Python Football Review #005!
Today we add two more creativity metrics to our analyst’s tool belt: xGChain and xGBuildup.
By the end of this issue you’ll know
what each metric measures
which gap they fill (left by xA and xAG)
which deep-lying playmakers have posted the best build-up numbers this season
which wing-backs top the charts for participation in attacking sequences
how to pull xGChain and xGBuildup in Python in seconds
Enjoy!
But Martin, why do we need yet another way to judge creative talent?
So far we’ve covered:
xAG — gives the shot’s xG to the player who plays the final pass.
xA — assigns every completed pass a probability of eventually becoming an assist.
Both reward the player closest to goal but overlook the initiators:
deep pivots who progress play (the Rodris and Jorginhos)
centre-backs who split lines (the John Stones and Virgil van Dijks)
wing-backs who join the build-up (the Cafus and Kyle Walkers)
Because these actions start far from goal, they accrue only modest xA and almost no xAG.
That’s the gap xGChain and xGBuildup are designed to close.
1 — What are xGChain and xGBuildup?
xGChain gives every player who touches the ball in a possession the shot’s xG if that possession ends in a shot.
Example: a move ends with a 0.25-xG shot. Every participant—keeper to striker—adds 0.25 to their xGChain total.
Three details matter:
The simplest touch and a forty-yard carry count the same if they’re in the same chain.
No shot → 0 xGChain for everyone in that possession.
Because credit is copied to each player, the squad’s summed xGChain will exceed the team’s match xG—so this is a player metric, not a team one (even though we can use it to analyse team structure, more on that below).
Great for spotting who helps attacks reach the box: xAG credits one passer; xGChain credits everyone involved.
Why xGBuildup then?
Rank players by xGChain and advanced attackers still top the list—they finish and assist, so they appear in nearly every chain. To surface the early-phase contributors we use xGBuildup:
Start with xGChain.
Exclude the players who made the final two touches—the key pass and the shot.
What remains is xGBuildup.
Some elite attackers still rank highly even after you strip away their shots and assists; that simply means they also contribute in the build-up—valuable context.
And yes, expect Lionel Messi to still pop up near the top (not that you needed yet another metric to remind you of this).
Okay, moving on…
2 — How analysts use xGChain & xGBuildup
There are two main applications:
Scouting and player evaluation – surfacing deep-lying contributors who rarely appear on assist charts.
Tactical profiling – mapping where a team’s build-up flows without watching a single minute of video.
Below are quick case studies from the 2024/25 season (Europe’s top five leagues). You’ll be able to reproduce the tables in Python later.
2.1 — Scouting & evaluating players
Top xGBuildup/90, 2024-25
Okay, so who were the players that topped the xGBuildup per 90 minutes rankings during the past season? Because xGBuildup strips out shots and key passes, the leaderboard is dominated by midfielders and defenders—exactly the roles we want to judge.
Vitinha sits miles clear at 1.18 xGBuildup/90—on average he takes part in attacking sequences worth 1.18 xG every match.
His midfield partner Fabián Ruiz follows at 0.97, underlining PSG’s central dominance.
Two full-backs—Nuno Mendes (0.91) and Achraf Hakimi (0.89)—both rank in the top four, suggesting PSG’s build-up is well balanced across flanks.
As expected, the list is almost entirely midfielders and defenders once key-pass credit is removed.
Top xGChain/90, 2024-25
Including the shot and assist brings attackers back into view.
Ousmane Dembélé tops the table at 1.65 xGChain/90—fitting for a player who re-invented the false-9 role in PSG’s historic season. No wonder he is now a Ballon d’Or favourite (hands up if you predicted that last August; I certainly didn’t).
Gonçalo Ramos makes the list despite limited starts; his touches keep showing up in scoring moves even when he isn’t the one shooting.
Bradley Barcola and Khvicha Kvaratskhelia round out the top four, underlining just how balanced PSG’s attack (and, as we saw earlier, their build-up) has been.
2.2 — Assessing team patterns
But Martin, didn’t you say xGChain and xGBuildup are player metrics?
I did—yet comparing a few key players can still reveal where a team’s build-up flows.
Earlier we saw Achraf Hakimi (right) and Nuno Mendes (left) posting almost identical xGBuildup figures, suggesting PSG advance play down both flanks in roughly equal measure. Let’s apply the same lens to Arsenal.
Arsenal wide balance, 2024-25
This season Gabriel Martinelli often looked isolated on the left. The numbers agree.
Saka is involved earlier and more often (0.31 vs 0.17 xGBuildup/90), pointing to a right-heavy build-up bias. The narrower gap in xGChain (0.84 vs 0.66 xGChain/90) shows Martinelli does contribute more in the final phases, but the attack tilts right from start to finish.
Arsenal centre-backs
Saliba and Gabriel drive progression from the back. When Jakub Kiwior steps in, Arsenal lose roughly 0.13 xGBuildup per 90 at centre-back—a reminder that depth matters if your system relies on ball-playing defenders to start attacks.
2.3 — Things to watch out for
Team style inflation – Possession-heavy sides naturally inflate xGBuildup (I am looking at you, Pep); always benchmark within league and pace context.
Direct teams – A low xGBuildup doesn’t always mean a player is conservative; the ball might bypass midfield altogether (think Leicester’s title-winning 15/16 campaign).
Double counting – Forwards with huge shot volumes can dominate xGChain leaderboards. Subtract the player’s own xG if you want non-shooting influence.
Sample size – Use per-90 numbers and set a sensible minutes threshold (e.g., >900 mins) to avoid noise.
Great, now that we have covered those, let’s do some coding.
3—How to Fetch xGChain and xGBuildup Data Using Python
Here’s how to pull xGChain and xGBuildup yourself.
If you’re new to Python, the quickest route is Google Colab—a free, browser-based notebook that needs zero local setup.
Go to https://colab.research.google.com and sign in with your Google account.
In Colab, click File → New notebook.
You can paste the snippets below or download the full notebook:
We’ll use two libraries:
soccerdata
, a community wrapper by Pieter Robberechts that scrapes Understat.polars
, our preferred dataframe engine.
In the example below we pull Europe’s top-five leagues for the 2024/25 season. You can add any season from 2014/15 onward by extending the list.
Next we run a simple read_player_stats()
to pull the player stats for the season and then transform the resulting pandas
dataframe into a polars
one with from_polars
.
At this point you’ll see a wide table with dozens of columns—one row per player × season.
Next, we’ll keep only the variables we care about—season, team, player, position, minutes played, and their xGBuildup and xGChain values—and then calculate the corresponding per-90 figures.
Next, we replicate the tables from the case studies. First, we filter for players who have appeared in at least 10 matches and return the top ten in xGBuildup per 90 minutes.
And here we simply change the sorting parameter to xg_chain_90
to order the players by that metric.
And here’s the coding bit for focusing only on Saka and Martinelli
And the bit for focusing on Arsenal’s three central defenders.
You can now fire up Python and explore other seasons, teams, and players to see what the underlying data reveals.
Boom—that was xGChain/xGBuildup 101.
If you found this issue useful, please spread the word!
You now know more about these two metrics than most football fans: what they measure, how to use them, why they shouldn’t be underestimated, and—crucially—how to pull extensive data with just a few lines of Python.
Until next week,
Martin
The Python Football Review
Brilliant stuff 👏🏼👏🏼
More good stuff Martin, thanks!