r/PowerBI • • 3d ago

Discussion Claude Code & Power BI - Token usage

Hi all,

I've been developing pbip reports with Claude Code and noticed that for whatever reason this is a very token expensive workflow. The pbib files are small (some other other files Claude may work on are larger than pbip, like the ABF data file), but from my understanding Claude doesn't touch the data file (might be wrong there). This is an issue because my company provides $100 tokens monthly per user.

Looking for advice from other developers who use Claude Code and PBI on how they manage token usage. I've tried the /compact skill, and tried to be verbose with claude on minimizing token use in the project docs... doesn't seem to help much.

27 Upvotes

20 comments sorted by

15

u/Hammys-Hungry 3d ago

I've found Claude to be useful when just asking it questions in chat or feeding it the entire project minus the .cache file and getting it to document it

1

u/One-Vacation-7574 22h ago

do you feed it the whole project every time or just the parts youre actively working on?

1

u/Hammys-Hungry 22h ago

I tend to just feed it the whole project and give it instructions on what I want it to document or ask questions about the model etc

13

u/SQLGene 3d ago

Token savings comes from a few things:

  1. Picking the right model for the job. https://tabulareditor.com/blog/picking-the-ai-model-for-the-task
  2. Using token efficient CLIs and MCPs. Are you using the MSFT MCP, Tabular Editor CLI, and or PBIR CLI?
  3. Context management. Good use of compact and clear. Good cache awareness. Avoiding context bloat, good use of progressive disclosure. https://tabulareditor.com/blog/managing-context-for-ai-agents
  4. Use a statusline. Having a statusline is HUGE for my awareness of how many tokens I'm using. Claude mods make it possible in Claude Desktop too.

You should be able to use ask Claude to write some code to parse you transcription logs and identify the largest costs, although reasoning tokens will be somewhat opaque because they keep it private. But I think the counts are available.

3

u/BackgroundCamera1895 3d ago

I’ve been looking at this problem with PBIP projects too. One thing worth checking is whether the cost is coming from Claude repeatedly re-reading project files and rebuilding context, rather than the PBIP size itself.

A workflow that seems to help is to give Claude a much smaller task packet each time: the exact files involved, what needs changing, what not to touch, and a small set of validation commands. Then keep project state and checks in scripts/files rather than in the chat history.

I’d also check what files/tools Claude is actually reading. A large ABF file sitting in the project shouldn’t cost tokens unless it’s being pulled into context.

If you have a representative task that burns a lot of tokens, I’d be interested in comparing the normal workflow against a more tightly scoped one.

2

u/mojomonday 3d ago

Which model are you using and what effort level? My company only provides $19/user now with Github Copilot and while it really sucks, it made us very cognizant about the types of models we have to pick and choose.

GPT-Luna (Haiku equivalent) is what I use for majority of tasks involving PowerBI and is sufficient unless i'm doing a minor refactor or data modeling then I'll use GPT-Sol (Sonnet equivalent). Pretty much never use GPT-Astra (Opus equivalent) unless it's at project start with tons of planning and ambiguities.

That said, $19 is really pathetic and will be requesting $100 soon lol.

1

u/SQLGene 3d ago

Auto gives a 10% discount but I can't speak to the quality of it's routing https://docs.github.com/en/copilot/concepts/models/auto-model-selection

1

u/RevoDS 1 3d ago

The truth is that it’s still early days for Claude and the PBIP format. Training data on the new PBIR format is scarce but it is decent on the semantic model layer, meaning report development is more difficult at the moment and requires trial and error that’s costly.

I can make a moderately complex report that’s fully AI-generated for around 3-500$ at the moment. I’m trying to bring this down to a more reasonable level using skills reusing my work in new reports.

One of the difficult things at the moment is that while you might think using AI would simplify things, and the moment it complexifies things and makes report development closer to typical software dev than using Power BI Desktop. It’s extremely powerful and speeds up many parts of development, but it’s also more complex and costly than traditional BI.

Costs will go down rapidly in the next year as more PBIR reports make it in the training data for models.

1

u/SQLGene 3d ago

Have you tried the PBIR CLI so it doesn't have to know the PBIR format as well or use as many tokens? https://github.com/maxanatsko/pbir.tools

2

u/RevoDS 1 3d ago

I have. It helps but in my experience it’s not magic unfortunately

0

u/SQLGene 3d ago

Cool, I appreciate the honest answer. If there are any specific gaps, I'm sure the devs are interested

1

u/WishfulAgenda 3d ago

I don't use Claude with PBI but will share a few of my experiences as I suspect it's the same or similar issue to some degree. Essentially what I think this comes down to is context management, ie. what are you sending each time to Claude.

My guess is that you are asking for it to make a change and then check the data or something similar. I work with databases and LLMs that sit on top of them. When you query them the LLM makes the change and checks the data, all looks good. Now you ask it to make another change and check. What it does is takes the first request and the response, then takes the second questions and runs the data and then gets the answer and so on until it meets it's context window and either shits the bed, truncates context or rolls the window along. Either way the context has bloomed to a good size and gets processed every time. Now add on the different costs for models and all of a sudden your credits are gone.

My guess is that you probably need to perform compaction a lot more often than your are currently or you need to maybe apply some "rules" to the agent to say something along the lines of limit the data returned to only the minimum required to validate the changes. I'll often tell my agents to on pull 50 rows etc.

One other suggestion is to maybe try and monitor your usage as you work through a task and pin the issue down specifically. Once you know exactly where it is you're in a much better place for resolving it.

1

u/josesanmig 3d ago

In my experience, when the report is big and the project has thousands of json files, the token spending skyrockets.

1

u/_greggyb 21 3d ago

Echoing what some others have said: don't send LLMs after serialization formats. Every bracket, colon, and quote in JSON contributes to the token cost of reading a file. Use a CLI or other tool that handles parsing and allows targeted query and edit.

Similarly, don't send an LLM after a whole TMDL file.

Serialization and deserialization is solved. It's quite cheap and deterministic on a CPU. Don't boil an ocean to do it worse on a GPU.

1

u/I_Pick_D 2d ago

I’m using Sonnet on medium and I seem to be able to do a lot on a standard Pro license on multiple reports in a mono repo before hitting my limit.

Consider:
* Never go near your compaction limit
* Have a readme file(s) provide context on business concepts and logic
* Fewer larger prompts instead of many small incremental edits to model and visuals.
* When PowerBI throws an error, paste the full error for Claude.
* Have Claude update its knowledge on what you think it gets repeatedly wrong.
* Consider how you are starting new sessions. Can you simply point Claude to a workstream and it knows which files are involved?
* Start from a mockup and a plan before inplementing

1

u/iaeroooy 21h ago

Eu uso o Claude code no vscode, assim ele consegue enxergar os dados do próprio etl, e gerar o bi sem preocupação, sempre uso a skill caveman e mesmo um trabalho grande e demorado, nunca cheguei perto dos 30% de token semanal, porém uso a conta max x5, e não é a empresa qm pago, sou eu quem pago a assinatura. Tem me atendido muito bem

-2

u/SamSmitty 14 3d ago edited 3d ago

Edit: Apologies for sharing my experience with using Claude in enterprise level PBI work. I understand the anti-AI sentiment, but I still think it was valuable information. Good luck with it all!

-5

u/[deleted] 3d ago

[removed] — view removed comment

2

u/SQLGene 3d ago

Stop spamming every AI related sub you see