dataSights

Build SQL views with Claude

Last updated

A view is where report logic goes to live permanently. Instead of the joins and the calculations sitting inside one Power BI file or one workbook, they sit in your database as a saved query, and every tool reads the result. Claude can write and save one for you. This page is how, and what to do once it exists.

What you need

  • AI Connect connected to Claude, or whichever AI tool you use. How to use the dataSights MCP

  • The Create Report View permission, under AI Connect, then Data, on your user. Admins have it already.

  • The tables the view will read exposed to the AI in Select Views & Descriptions. Claude can only build from what it can see.

The steps

1. Start from an answer you trust. Do not ask for a view cold. Ask the question first: revenue by entity against last year, aged receivables over sixty days, margin by product. Look at the result. Check it against a number you know. Go back and forth until it is right. The view is the last step, not the first.

2. Ask Claude to save it. "Save this as a view called RevenueByEntityVsLY." Claude writes the SQL and saves it to your database through AI Connect. Name it for the question it answers, not the tables it reads; the name is what you and everyone else will see in Power Query, Power BI and Data Viewer. You can also ask Claude to save a description with it, for example "describe it as monthly revenue by entity, with last year alongside".

3. Check the description. The new view is added to AI Connect automatically, ready for the AI to use straight away. If Claude saved a description it is already there; if not, the view starts without one. Open Select Views & Descriptions, find it, and write or edit the description so it says what the view answers and who it is for. That description is what the next Claude conversation, and the next colleague, reads before using it.

4. Look at it. Data Viewer shows you the rows. Confirm it holds what you expect before anything is built on it.

5. Build on it. Point Power Query, Power BI, a web app, or the next conversation at the view. They all read the same clean table, and none of them needs to know how it was made.

Good to know

  • A view is a saved query, not a copy of the data. It is always current. Nothing to refresh, nothing to resync.

  • Slow view? Cache it. A view over full history across many entities can take a while to return. The Caching Service materialises it into a physical table on a schedule, and everything downstream reads the fast copy.

  • Changing it. Ask Claude to alter the view, or edit it in the SQL Editor. Everything built on it picks up the change on its next refresh, without touching the workbook or the dashboard.

  • Views Claude creates are ordinary database views. No lock-in, nothing proprietary. Any tool that speaks SQL reads them, and you can see and edit the definition in the SQL Editor at any time.

  • Two other ways to get a view without writing SQL. Select Create Report View on the AI Data Query screen after a query returns what you want. Or paste a query into the SQL Editor and save it there.

  • Moving logic you already have. If the calculation lives in Power Query or in DAX today, it does not need rebuilding; it needs moving up. Excel Power Query → SQL and Move DAX / modelling from Power BI → SQL.

dataSights

Try dataSights free

See how dataSights automates your Xero consolidation and reporting. Start your 14-day free trial, no credit card required.

Start for free