/custom-visuals:performant-matrixfrom custom-visuals
Diagnoses and fixes slow Power BI financial matrices by separating row-dispatch cost from per-cell format-string and conditional-formatting overhead. Guides users through bridge table, native restructure, or Deneb grid remedies.
Ships in custom-visuals. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Report modification requires tooling. Two paths exist:
pbirCLI (preferred) -- use thepbircommand and thepbir-cliskill. Install withuv tool install pbir-cliorpip install pbir-clion macOS or Windows; on Linux run thepbir-cliskill'sbin/install-linux.sh, which installs the Windows build under Wine (path 2 only where there is no Wine). Check availability withpbir --version.- Direct JSON modification -- if
pbiris not available, use thepbir-formatskill (pbip plugin) for PBIR JSON structure and patterns. Validate every change withjq empty <file.json>.If neither the
pbir-cliskill nor thepbir-formatskill is loaded, ask the user to install the appropriate plugin before proceeding with report modifications.
The shape this skill is for: a P&L matrix whose rows or columns are dispatched by a SWITCH(SELECTEDVALUE(...)) over a disconnected table, or by a calculation group on an axis. It takes seconds to render, it gets worse every time a row is added, and past a certain size it stops rendering in the Power BI Service at all.
Order: DIAGNOSE, then CONSULT, then BUILD. There are three remedies and they fix different costs. Do not start building until the measurement says which cost dominates and the user has picked a remedy. Deneb is one of three outcomes, and on account-shaped rows it is the wrong one (bridge 348 ms cold against Deneb 294 ms cold: not worth a custom visual).
| Cost | Paid per | Visible to EVALUATE? | Remedy |
|---|---|---|---|
| (a) Row dispatch | query plan | yes | bridge table, or a Deneb grid |
| (b) Dynamic format strings | rendered cell | no | the per-cell ladder |
| (c) Conditional-formatting colour measures | rendered cell, per colour slot | no | the per-cell ladder |
(b) and (c) are invisible to every DAX benchmark you will run. An EVALUATE returns raw values and never evaluates a formatStringDefinition, so a visual can be far slower than the query behind it while the DAX profile looks innocent. That is why the subtraction, not the query timing, is the diagnostic.
Mechanism for (a): one query plan is built for the whole group, not one per cell. When the dispatch column is grouped on rows, the engine must compile a single plan capable of producing every row of that group, so every branch, every measure under it, and every measure under those gets materialised. Branch pruning cannot fire, by construction. A calculation group on an axis is the same mechanism wearing different syntax, and its cost is items x measures.
Corollary: a card is not affected. When a slicer filters the dispatch column to one value instead of grouping it, pruning fires and there is nothing to win. Only the grouped-rows case is broken.
Two things invalidate everything downstream, so do them first.
ROLLUPADDISSUBTOTAL on the grouped column and the flat shape needs its ALLSELECTED total measures. Drop either and you timed a different visual: on the diagnosed matrix, removing the 36 ALLSELECTED total columns took a flat query from 1,580 ms to 819 ms cold.Then take three readings, all under the same pinned context:
scripts/run_dax.ps1 -QueryFile .\dispatch.dax -Runs 2.examples/flat-query.dax.Run each at least twice: run 1 cold, run 2 warm. Measurement mechanics (port discovery, the ADOMD DLL, cold vs warm) are in references/diagnosing.md.
Two supporting signals, neither of them a gate:
The flat query is the floor. No visual technique goes below it. If the flat number is already most of your target, stop: this is a measure problem, not a visual problem. On the lab model that floor is 17 ms warm; on a model whose base measures cost 800 ms, 800 ms is what you get.
| Symptom | Likely cost |
|---|---|
| PA total is close to DAX time; the dispatch query costs much more than a flat query of the same base measures; DAX time scales with branches, not with fact rows | (a) row dispatch |
Rows or columns come from a calculation group rather than a SWITCH | (a) row dispatch, same mechanism |
PA total is much larger than DAX time; the value measure appears inside its own formatStringDefinition | (b) format string |
| PA total is much larger than DAX time; several colour measures bound to conditional formatting | (c) CF measures |
| Both (a) and (b)/(c), and the layout is a fixed grid you control | all three at once |
| The flat base-measure query is already most of the dispatch query | the measures are the floor |
Rows 1 and 6 are not exclusive. The diagnosed matrix was both at once: roughly 500 ms of warm dispatch overhead sitting on a 1,500 ms warm measure floor, which is why a structural fix alone would not have carried it.
The defining step. Do not proceed until it is answered. Two pre-checks fire before the question is asked.
Pre-check 1 (do not consult, just stop): if the flat base-measure query is already most of the dispatch query, say:
Your measures are the floor, not the visual. The flat query over the same base measures is
<B>ms against a<A>ms dispatch query, and no visual technique goes below<B>ms. Fix the measures or put fewer on screen; rebuilding the grid buys you<A - B>ms at most.
Pre-check 2 (present two options, not three): if the bridge gate below fails, drop option 1 and name the clause that failed.
The consultation block is in references/consultation-block.md:
present it filled in with the pinned-context numbers (row dispatch, per-cell tax, measure floor) and
the three ways forward. In short: 1 bridge the model when the rows are an account set and the
model can change; 3 a Deneb grid when they are not; 2 a native restructure when the model is
frozen.
Then ask only what the block above has not already answered:
If the user names a mixed statement, add: "Rows that are account sets can go on the bridge and ratio rows can stay ordinary measures, and one grid renders both. Want the mixed build?"
references/bridge-method.md for the build and migration recipe, examples/bridge-table.tmdl for the table, relationship and one bridge measure. This is a model change: route TMDL edits through the pbip:tmdl and semantic-models:semantic-model skills.references/per-cell-tax.md for the TMDL syntax and the self-referencing-format-string audit script.references/deneb-grid-template.md for the dataset contract, transforms and PBIR embedding. Author the spec with custom-visuals:deneb-visuals, round-trip and offline-render it with custom-visuals:deneb-pbir. Dispatch the deneb-reviewer agent before presenting the spec to the user.Report-file edit safety (clone-and-compare, the filter-name census, validate baselines) is in references/pbir-build-safety.md.
Put old and new measures in the same query over the same grouping and count mismatches. The gate is zero. Two eyeballed screenshots are not a tie-out: a missing (line, account) pair produces a smaller number, not an error.
examples/tie-out.dax has the shape, including the + 0 guard: COUNTROWS over an empty filter returns BLANK, not 0, so without it a clean tie-out is indistinguishable from a query that never ran. Repeat under every slicer state that matters.
Applies when the statement's rows can be written as "which accounts or keys does this row cover". The row axis then becomes a filter and there is no dispatch DAX at all.
Does not apply when any of these is true for a meaningful share of rows:
ALLSELECTED, which is filter-context manipulation and cannot be expressed as membership in an account list.Two shape checks before committing. Signs: the pattern assumes costs are stored negative so every subtotal is a plain sum; otherwise the bridge needs a Sign column and a SUMX, which puts the iteration back. Join key: match on AccountKey, never on the display label, or a renamed row silently blanks that line.
Blast radius: do not skip. Bidirectional filtering on a shared dimension can create ambiguous filter paths. Desktop will either refuse the relationship or, worse, accept it and change the answer for measures that had nothing to do with the P&L. Re-check other visuals that touch the account dimension. RLS is a separate switch (securityFilteringBehavior = BothDirections, off by default). If the model will not take it, fall back to the TREATAS variant or to CROSSFILTER(..., BOTH) scoped inside the bridge measures only.
Not exclusive. A mixed statement puts its account-backed lines on the bridge and its ratio lines on ordinary measures, then renders both through one grid.
Applied in order. The grep target for cost (b) is a formatStringDefinition that opens VAR _VALUE = ABS ( [X] ): the cell evaluates [X] for its value, then the format string evaluates [X] again to decide how to print it.
formatString. The tax goes to zero because there is nothing to evaluate. Only valid when every cell in the column lives in the same order of magnitude.FORMAT over a VAR you already computed, so the double evaluation disappears. Cost: the column is text, so no sort by value, no data bars, no numeric aggregation. Untested: the mechanism is clear but the delta was never measured.fieldValue colour column beats a measure. Keep measure-driven CF only where the colour genuinely depends on the number.Read references/gotchas.md before rebuilding. The two that cost most:
replacing a SWITCH with a calculation group on rows made the same cells 4.5x slower, and
IFERROR on every branch more than doubled the cost. A clean pbir validate and a clean DAX
profile are not evidence the visual is fast: the canvas is the referee.
| Constraint | Desktop | Service |
|---|---|---|
| Dispatched matrix past a few hundred evaluations | very slow | may fail to render at all |
Per-cell tax visible to EVALUATE | no | no |
| Performance Analyzer cache state | not reported | n/a |
| Deneb grid: native sort / export / drill / CF pane | none | none |
| Bridge: bidirectional relationship | may be refused as ambiguous | same |
| RLS across a bidirectional relationship | off unless securityFilteringBehavior is set | same |
Bridge when the rows are an account set and the model can take the relationship. It gets 99% of the improvement Deneb gets, it stays a native visual, and it is a one-off model change every future visual inherits. Measured A/B on that shape: bridge 348 ms cold against Deneb 294 ms cold. The bridge wins on effort, not on time.
Deneb when the rows are not an account set, and then it is not close: 419 ms against 1,680-7,530 ms for every native alternative on the same rows. Also choose it where the bridge applies if you want client-side formatting and colour and you accept rebuilding the grid chrome by hand.
Native restructure when the model is frozen. It buys back the per-cell tax and leaves dispatch alone.
Neither, when the measures are the floor. The grid removes dispatch, per-cell format strings and per-cell conditional formatting. It does not make SUM over 74.9M rows faster.
references/diagnosing.md -- measurement mechanics: port discovery, the ADOMD DLL, pinning the filter context, cold vs warm, the scan-count heuristicreferences/bridge-method.md -- the bridge build, migration recipe and tie-outreferences/per-cell-tax.md -- format-string and CF mechanics, TMDL syntax, the self-reference audit scriptreferences/deneb-grid-template.md -- the grid implementation spec: dataset contract, transforms, client-side formatting, PBIR embeddingreferences/measured-results.md -- all nine lab pages under one protocol, the table to quotereferences/pbir-build-safety.md -- safe edit mechanics on a live reportreferences/consultation-block.md -- the Step 5 block to present: the three costs measured and the three remedies with what each buys, costs and keepsreferences/gotchas.md -- hard-won traps: calculation groups on rows, IFERROR, calendar-registered columns, null in Deneb, format-string precedenceexamples/flat-query.dax -- the flat base-measure probe that establishes the measure floorexamples/tie-out.dax -- old against new in one query, with the + 0 blank guardexamples/bridge-table.tmdl -- bridge table, relationship and one bridge measurescripts/run_dax.ps1 -- times a .dax file against the open Desktop model over ADOMD, cold and warmExternal: Understanding the optimization of SWITCH (Russo and Ferrari, SQLBI) is the load-bearing reference for cost (a).
To retrieve current Power BI performance and modelling docs, use microsoft_docs_search + microsoft_docs_fetch (MCP) if available, otherwise search https://learn.microsoft.com and fetch the relevant pages. Search based on the user's request and run multiple searches as needed to ensure sufficient context before proceeding. Note: Vega/Vega-Lite docs live at vega.github.io (not MS Learn) -- use WebFetch for those.
deneb-visuals -- Vega/Vega-Lite spec authoring, theme colors, interactivity (the Deneb branch)deneb-pbir -- extract/embed the spec in visual.json + offline render to verify without Power BIsemantic-model (semantic-models plugin) -- the bridge branch is a model change: bridge table, relationship, RLS filtering behaviortmdl (pbip plugin) -- direct TMDL edits for the bridge table and format stringsdax-optimisation (semantic-models plugin) -- when the flat base-measure query IS the floorpbir-format (pbip plugin) -- PBIR JSON format referencepbi-report-design -- layout and design best practicesexamples/bridge-table.tmdl (opens in a new tab)examples/flat-query.dax (opens in a new tab)examples/tie-out.dax (opens in a new tab)references/bridge-method.md (opens in a new tab)references/consultation-block.md (opens in a new tab)references/deneb-grid-template.md (opens in a new tab)references/diagnosing.md (opens in a new tab)references/gotchas.md (opens in a new tab)references/measured-results.md (opens in a new tab)references/pbir-build-safety.md (opens in a new tab)references/per-cell-tax.md (opens in a new tab)scripts/run_dax.ps1 (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
power-bi, financial-matrix, performance-tuning, dax-optimization, deneb
npx claudepluginhub insightfulanalytics/pbi_agentic_dev --plugin custom-visuals7 skills in this plugin
/deneb-pbirRound-trip TOOLING for Deneb specs in PBIR. Extract/embed the Vega/Vega-Lite spec in visual.json, offline-render it to PNG/SVG, audit a visual's Deneb 2.0 stamps and migrate container signal names. Use whenever a task edits a Deneb visual's spec ("edit the Deneb visual", patching jsonSpec) or needs it rendered without Power BI. Authoring rules live in custom-visuals:deneb-visuals./deneb-visualsDeneb visual creation, Vega/Vega-Lite spec authoring, and Deneb best practices for PBIR reports. Automatically invoke whenever the user mentions "Deneb" in any context, or asks about Vega/Vega-Lite specs in Power BI, Deneb cross-filtering, Deneb interactivity, pbiColor theme integration, Deneb field name escaping, or Deneb rendering issues./powerbi-custom-visualsPower BI custom visual (.pbiviz) development with the pbiviz toolchain and its MCP server. Automatically invoke when the user mentions "custom visual", "pbiviz", "develop a Power BI visual", "powerbi-visuals-tools", "IVisual", "capabilities.json", "visual formatting model", "visual certification", "publish a visual to AppSource", or asks to scaffold, build, debug, package, certify, or publish a .pbiviz developer visual./python-visualsPython visual creation and matplotlib/seaborn patterns for PBIR reports. Automatically invoke when the user mentions "Python visual", "matplotlib in Power BI", "seaborn in Power BI", "pythonVisual", or asks to "create a Python visual", "add a matplotlib chart", "write a Python visual script"./r-visualsR visual creation and ggplot2 patterns for PBIR reports. Automatically invoke when the user mentions "R visual", "ggplot2", "ggplot in Power BI", or asks to "create an R visual", "add an R chart", "write an R visual script", "inject an R script into Power BI"./svg-visualsSVG generation via DAX measures and extension measures with ImageUrl data category for inline visualizations in PBIR reports, including ready templates for matrix and table cells, new card images and per-button images on the new button slicer. Automatically invoke when the user mentions "SVG visual", "DAX sparkline", "SVG measure", "inline graphics with DAX", "ImageUrl data category", "extension measure", or asks to create any DAX-generated chart (progress bars, bullet charts, KPI indicators, data bars, gauges, donut charts, lollipop charts, dumbbell charts, status pills, overlapping bars, boxplots, IBCS bars, jitter plots, box-and-whisker charts).Other plugins' skills for the same job