Claude Code 以 ClickHouse 即時模型建立 Power BI 報表
Claude builds a Power BI report on a live model in ClickHouse
Claude Code 透過 eMondrian MCP 讀取 ClickHouse 上的語義模型,生成可在 Power BI Desktop 開啟並即時連線的報表專案。首次生成用時 3 分 28 秒,包含年份及承運商切片器、KPI 卡及圖表;之後依提示新增按星期顯示取消率的圖表,耗時 2 分 29 秒。代理只讀取模型,不接觸原始資料表或資料列,報表保持與模型即時連線。
As of October 2026. You need Windows with Power BI Desktop and Claude Code. Nothing else to install.
Last week I showed Claude building a live dashboard on 182 million flights. The most common question afterwards: can it do that in Power BI? That's where most BI teams actually live.
It can. In this tutorial an AI agent builds a real Power BI project, a page with slicers, KPI cards and charts, with a live connection to a semantic model on ClickHouse. Then you look at it in Power BI Desktop, ask for a change, and look again. Nothing is imported into Power BI, and there's no copy of the data.
It runs against the public eMondrian demo, so you don't install a server. The agent took about three and a half minutes for the first version and two and a half for the change.
Disclosure: I'm the author of eMondrian, the open-source semantic layer used here.
What you'll build
- Year and carrier slicers
- KPI cards: flights and on-time rate for the selection
- On-time rate by year, and by month for the selected year
- The largest carriers by flights
- After the change: cancellation rate by day of week
The agent wrote every page and visual. I typed two prompts and didn't touch the files.
How it works, in one paragraph
Power BI Desktop can save a report as a project (PBIP): a folder of JSON files, one per page and per visual. An agent can write those files. The model lives in eMondrian, an open semantic layer on ClickHouse, where measures like On-Time Rate are defined once. Power BI connects to it live through its Analysis Services connector and sends DAX, the same way it talks to Analysis Services. The agent never sees raw tables or rows: it reads the model, generates the report files, and validates them before it hands them over.
Step 1. Connect Claude Code to the demo (1 minute)
In an empty folder:
claude mcp add --scope project --transport http emondrian https://demo.emondrian.com/emondrian/mcp
This writes a .mcp.json into the folder; Claude Code asks you once to allow the server when it starts. The demo is public and its data is read-only: 182 million US flights in ClickHouse, behind a model called OnTime.
Step 2. Ask for the first version (3½ minutes)
Start claude in that folder and paste:
Using the eMondrian MCP server, build a Power BI report on the OnTime catalog: a page "On-time performance" with year and carrier slicers, KPI cards for flights and on-time rate, on-time rate by year (line), by month for the selected year, and the largest carriers (bar). Live connection to the model, no import. Validate the report before you finish. Power BI should connect live to https://demo.emondrian.com/xmla.
I ran it in a brand-new Claude Code session; the folder held nothing but the MCP configuration. The agent:
- read the model: catalogs, the cube, and the field names Power BI will use. That's how it found On-Time Rate already defined instead of inventing its own formula;
- generated the project: page, seven visuals, layout, connection;
- validated it against Power BI's schemas and the model before writing anything to disk;
- wrote the files and checked the 2025 numbers with one query against the server.
3 minutes 28 seconds, 30 tool calls. One hiccup: on Windows, its first attempt to write all files in one long shell command failed. It noticed, checked that nothing had been written, and wrote the 18 files one by one.
The result is an ordinary Power BI project folder: a .pbip file and a definition folder with one JSON file per page and visual. Every file is exactly what the generator produced; the agent didn't hand-edit anything.
Step 3. Open it in Power BI Desktop
Double-click the .pbip file. No preview settings to switch on, no sign-in: Power BI connects live to the demo, and every visual sends a query when it renders.
A few things the generator decided, the way a person would:
- The year slicer opens on 2025, the latest complete year. 2026 is in the list, but it only has seven months.
- The cards show the exact number, 7,001,619, not "7M".
- The year line ignores the year slicer, so it keeps all years instead of collapsing to a single point. The carriers bar likewise ignores the carrier slicer, so you still see the ranking.
Now pick DL (Delta) in the carrier slicer:
The numbers are the same as in last week's Claude dashboard on the same model: 7,001,619 flights in 2025, on-time rate 76.34%; Delta 1,026,332 flights, 79.12%. That's the point of a semantic layer: Excel, Power BI and the AI agent get the same measure, defined once.
Step 4. Ask for a change (2½ minutes)
Leave Power BI Desktop open, and in the same Claude Code session:
Add a chart with cancellation rate by day of week for the selected year and carrier.
The agent noticed that Power BI Desktop was running. Before writing, it asked me to save any edits there, because Desktop's next save would overwrite its files. Then it added the chart, laid the page out again in two rows so the year line keeps its width, and validated the report. 2 minutes 29 seconds including my answer, 11 tool calls, no errors. It changed the positions of three charts and added one file; nothing else.
Desktop notices the change by itself:
Step 5. Look at the change
Click Apply external changes. The page reloads with the new chart, without reopening the report:
In 2025, across all carriers, Sunday had the highest cancellation rate, 1.73%, and Tuesday the lowest, 1.18%. Delta was different: Friday was its worst day, 1.73%, and Wednesday the best, 0.49%.
Doing this on your own data
- Run eMondrian Community next to your database:
git clone https://github.com/eMondrian/emondrian-communityand./setup.sh. It works with ClickHouse, PostgreSQL, MySQL or any JDBC source. - Describe your cubes and measures. You can ask Claude to draft the schema over MCP; it validates and saves it.
- Ask for a report, exactly as above, with your server's address instead of the demo's. The agent works from the model, so it never needs your raw tables.
The Power BI and AI modules need a key; a free 30-day evaluation key is at emondrian.com/license. Community's MCP server has no sign-in, so keep it on your own machine or a trusted network.
eMondrian: Demo · GitHub · Docs
Sources: Power BI Desktop projects (PBIP) · PBIR report format
Questions, or a report you built this way? Leave a comment.
來源:DEV Community · dev.to





