Build a Custom Tableau KPI Extension with Claude Code
A live, unpolished build of a KPI card viz extension with Claude Code: big number, sparkline, config options and period over period, hosted on GitHub Pages, errors and all.
The short version
Eric runs a live session where attendees load his KPI card viz extension into their own Tableau Desktop from a .trex that points at GitHub Pages, then watch him change it with Claude Code. The card needs two fields, a measure and a date, and replaces the stack of sheets and five or six calculated fields a native KPI tile usually takes.
Over the hour he prompts for a sparkline, fixes a background color bug, adds number abbreviation and decimals, and works on period over period comparison. Not everything lands. GitHub Pages is slow to update, extension caching hides changes, two concurrent chats step on each other, and the period over period labels still need work at the end.
Along the way the group talks through when an AI powered extension needs an API key, why token cost scares people, the difference between dashboard and viz extensions, and how Eric really works: short iterations side by side with Tableau, plus a version badge so you know which build you are looking at.
The breakdown
A KPI card is a two field problem, not a five calc problem
Natively, a KPI card with a big number, a trend sparkline and a period over period change means objects stacking up on a dashboard. Eric says he counted five or six calculated fields for a single measure on a recent dashboard, because the data source did not already have them.
The viz extension only needs a measure and a date. Everything else, the comparison, the trend, the formatting, lives in the extension and its config.
You only need an API key when the extension has to think dynamically
Asked whether extensions need API tokens, Eric says the KPI card does not. If you are specific about what the extension should do, such as analyzing calculated fields and their dependencies, it is static code and just runs.
If you want it to answer questions about the data, or summarize a dashboard that changes on every refresh, the simplest route is an API key to a model. He mentions burning through a month of API balance in one evening when a setup was not efficient, and that going through Claude Code or Claude Desktop is much cheaper.
A .trex pointed at GitHub Pages lets everyone run the same build
Attendees open a new sheet, pick Extension from the Marks dropdown, choose Access Local Viz Extensions and select the downloaded .trex. Tableau shows the developer and the URL, which points at the GitHub repo, and the card asks for a measure and then a date.
The idea is that as Eric pushes changes, anyone can reselect the extension from the Marks dropdown to pick them up. The first card shows SUM(Sales) at 2.3 million, which Eric checks against a plain sheet.
Viz extensions live on a sheet, dashboard extensions see the whole dashboard
The KPI cards are viz extensions: they sit on a worksheet and render that sheet's marks. Eric shows a dashboard extension he built on the latest Makeover Monday data that finds map locations on the dashboard and interacts with them, plus an animated radar.
Josh points out that for a dashboard summary, a dashboard extension is the stronger choice, since you can attach all your worksheets and give it broader context.
When describing a bug fails, send a screenshot
A viewer notices the background color setting changes a layer behind the card, not the card itself. Eric describes it to Claude Code, pushes, refreshes, and it is still wrong. So he drops in a screenshot, since Claude is very good at reading images.
Meanwhile other config options work on the first try, including abbreviating large numbers to thousands or millions and setting decimal places.
Short iterations beat one giant spec, but the good prompt took four tries
Eric usually runs in auto mode and iterates in short loops with the extension open side by side. Plan mode up front, or a much more detailed prompt, can cut down the back and forth.
The long starter prompt he shared at the beginning was really prompt three or four in a series. He refined it until it worked the first time from a clean start.
Add a version badge, because you cannot tell what got deployed
GitHub Pages is not immediate, and refreshing an extension sometimes means adding it again from the same .trex. It gets hard to know whether a change made it through, so Eric asks Claude Code for a development version badge on the card.
He then switches the build to localhost with a local server to iterate faster. The missing sparkline turns out not to be a code bug: on refresh, Order Date had dropped to Detail, and moving it back to the date encoding brings the sparkline in.
Period over period only works once you define what period means
A viewer asks what type of period the card compares. Eric wants the config to define the current period and what prior means, with a small label that spells out the date range. The card currently follows the date pill's aggregation, so switching to continuous month changes the trend line.
The work gets messy. Two chats running on overlapping code miss each other's changes, extension caching hides updates until a new sheet breaks it, and by the end the sparkline works but the change labels still need troubleshooting. Eric says he will finish it and push it to the repo.
Key takeaways
- A KPI card viz extension needs only a measure and a date, which replaces several sheets and calculated fields.
- Static extensions need no API key; dynamic analysis or dashboard summaries are where a model connection, and its cost, come in.
- Pick a dashboard extension when the tool needs context from every worksheet, and a viz extension when it renders one sheet's marks.
- When a described bug will not go away, give Claude Code a screenshot.
- Add a version badge during development and iterate on localhost, since GitHub Pages and extension caching hide what is deployed.
- Do not run two chats on overlapping code; they miss each other's changes.
Watch this when
You want to see what building a Tableau viz extension with Claude Code really looks like, including the deploy lag, caching and half-finished features.
Mentioned in this video
- Build a Tableau KPI card extension with Claude Code →
The written walkthrough of this build
- 5:14A Tableau KPI card without calculated fields →
Why two fields replace a stack of calcs
- 42:27How to host a Tableau extension →
GitHub Pages vs localhost, covered live in the session
- 1:08:27
- The free Tableau extensions skill ↗
The skill Eric uses to build these
- The full Viz Extension Kit ↗
Every extension with full source
- 90 minute 1:1 build session ↗
Build one on your own data, includes the Kit
- Directed Analysis ↗
Eric's writing on this work