Skip to content
Development
Skill

/svg-visuals

SVG generation via DAX measures and extension measures with ImageUrl data category for inline visualizations in PBIR reports. Automatically invoke when the user mentions "SVG visual", "DAX sparkline", "SVG measure", "inline graphics with DAX", "ImageUrl data category",

From plugin
power-bi-agentic-development
84232 skills8 agents2 commands3 MCP
Install
$ npx -y skills add data-goblin/power-bi-agentic-development --skill svg-visuals --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/svg-visuals

Context preview

The summary Claude sees to decide when to auto-load this skill.

SVG generation via DAX measures and extension measures with ImageUrl data category for inline visualizations in PBIR reports. Automatically invoke when the user mentions "SVG visual", "DAX sparkline", "SVG measure", "inline graphics with DAX", "ImageUrl data category",

SKILL.md

svg-visuals.SKILL.md
name: svg-visuals
description: SVG generation via DAX measures and extension measures with ImageUrl data category for inline visualizations in PBIR reports. 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).

SVG Visuals via DAX Measures (PBIR)

> **Use `pbir` for every report mutation.** The `pbir-format` skill is read-only schema context. > If the CLI is unavailable or lacks an operation, stop and report the gap.

Generate inline SVG graphics using DAX measures that return SVG markup strings. These render as images in table, matrix, card, image, and slicer visuals. Store as extension measures in `reportExtensions.json`.

How It Works

1. A DAX measure returns an SVG string prefixed with `data:image/svg+xml;utf8,` 2. The measure's `dataCategory` is set to `ImageUrl` 3. Power BI renders the SVG as an image in supported visuals

Supported Visuals

  • Table (`tableEx`): `grid.imageHeight` / `grid.imageWidth` -- `references/svg-table-matrix.md`
  • Matrix (`pivotTable`): same as table -- `references/svg-table-matrix.md`
  • Image (`image`): `sourceType='imageData'` + `sourceField` -- `references/svg-image-visual.md`
  • Card/New (`cardVisual`): `callout.imageFX` -- `references/svg-card-slicer.md`
  • Slicer/New (`advancedSlicerVisual`): header images -- `references/svg-card-slicer.md`

Workflow: Creating an SVG Measure

Step 0: Design and Preview

Before writing DAX, design the SVG visually:

1. **Query the model first** -- use DAX Studio or Tabular Editor CLI to get actual values with the intended filter context. Use real numbers, not placeholders. 2. **Write static SVG to a temp file** -- save to `/tmp/mockup.svg` and `open` it in a browser to preview layout, colors, and proportions. 3. **Ask for feedback** before converting to DAX -- iterating on static SVG is far easier than on DAX string concatenation. 4. **Colors must be hex codes with `#`** -- e.g., `fill='#2B7A78'`. Never use `%23` URL encoding or named colors. Always hex.

Step 1: Create the Extension Measure

Create the extension measure in `reportExtensions.json` manually (see the `pbir-format` skill in the pbip plugin for JSON structure).

# Example using pbir_object_model (if available):
report.add_extension_measure(
    table="Orders",
    name="Sparkline SVG",
    expression='''
        VAR _Prefix = "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 30'>"
        VAR _Bar = "<rect x='0' y='0' width='50' height='30' fill='#2196F3'/>"
        VAR _Suffix = "</svg>"
        RETURN _Prefix & _Bar & _Suffix
    ''',
    data_type="Text",
    data_category="ImageUrl",
    display_folder="SVG Charts",
)
report.save()

Step 1b: Review

Before presenting the measure to the user, dispatch the `svg-reviewer` agent to validate syntax and provide design feedback.

Step 2: Bind to a Visual

Extension measures use `"Schema": "extension"` in the SourceRef:

{
  "field": {
    "Measure": {
      "Expression": {
        "SourceRef": {"Schema": "extension", "Entity": "Orders"}
      },
      "Property": "Sparkline SVG"
    }
  }
}

For **image visuals**, bind the SVG measure through `pbir add visual image --image`; see `references/svg-image-visual.md`.

Step 3: Validate

Validate with `pbir validate "Report.Report" --all` and inspect bindings with `pbir visuals bind "...Visual" --show`.

Prefer UDF Libraries Over Custom DAX

Before writing a custom SVG measure from scratch, check whether an existing UDF library already provides the chart type:

  • **PowerofBI.IBCS** (Andrzej Leszkiewicz) -- IBCS-compliant bar, column, waterfall, pin, small multiples, and P&L charts. Preferred for business reporting with AC/PY/BU/FC comparisons. Install from https://daxlib.org/package/PowerofBI.IBCS/
  • **DaxLib.SVG** (Jake Duddy) -- general-purpose sparklines, bars, boxplots, heatmaps, jitter, violin, progress bars, pills. Install from https://daxlib.org/package/DaxLib.SVG/ -- source at https://github.com/daxlib/dev-daxlib-svg
  • **PowerBI MacGuyver Toolbox** (Stepan Resl / Data Goblins) -- C# scripts that generate SVG measures via Tabular Editor

To check if a library is installed, look for functions/measures starting with `PowerofBI.IBCS.`, `Viz.`, `Compound.`, or `Element.`. Only write custom SVG DAX when no library function covers the required visualization. See `references/community-examples.md` for full function listings and additional libraries.

Installing UDF libraries

UDF libraries are installed into the semantic model, not the report. Use one of these tools:

  • **Tabular Editor CLI** (`te` command) -- use the `te-docs` skill for guidance
  • **Power BI MCP server** -- if available, use it to modify the model directly
  • **`connect-pbid` skill** -- connect to Power BI Desktop's local Analysis Services instance via TOM/PowerShell
  • **`tmdl` skill** -- edit TMDL files directly in a PBIP project (last resort)

DAX SVG Conventions

Measure Structure (VAR Pattern)

Every SVG measure must follow a strict VAR-based structure. Organize code into clearly separated regions:

SVG Measure =
-- CONFIG: Input fields and visual parameters
VAR _Actual = [Sales Amount]
VAR _Target = [Sales Target]
VAR _Scope = ALLSELECTED ( 'Product'[Category] )

-- CONFIG: Colors
VAR _BarColor = "#5B8DBE"
VAR _TargetColor = "#333333"

-- NORMALIZATION: Scale values to SVG coordinate space
VAR _AxisMax = CALCULATE( MAXX( _Scope, [Sales Amount] ), REMOVEFILTERS( 'Product'[Category] ) ) * 1.1
VAR _AxisRange = 100
VAR _ActualNormalized = DIVIDE( _Actual, _AxisMax ) * _AxisRange

-- SVG ELEMENTS: One VAR per visual element
VAR _Svg
Read more
Ships withpower-bi-agentic-development

Power BI AI skills and Power BI agents for Claude Code and GitHub Copilot: a plugin marketplace of Power BI skills, subagents, and hooks for semantic models, DAX, TMDL, reports, and AI dashboards. Includes Microsoft Fabric skills and Fabric agents. Weekly updates.

Get the whole plugin