smithery/cn-dataworks

pbir-template-extractor

Extract Power BI PBIR visuals into reusable templates. Use when users want to save an existing visual configuration as a template, standardize visual formats across projects, or add new visual types to the template library.

Installation

$ npx skills add smithery/cn-dataworks --skill pbir-template-extractor

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/cn-dataworks.

npx skills add smithery/cn-dataworks

Browse all from smithery/cn-dataworks

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 7,664 B
  • docs SUMMARY.md 254 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

PBIR Template Extractor

Extract existing PBIR visuals and convert them to reusable templates with placeholders.

When to Use This Skill

Use when the user wants to:

  • Save an existing visual as a reusable template
  • Create a new template type not in the library
  • Standardize a visual configuration for reuse
  • Extract a well-formatted visual from Power BI Desktop
  • Add to the visual-templates library

Workflow

Step 1: Locate Source Visual

Find the visual.json file to extract:

# List pages in the report
Glob: .Report/definition/pages/*/page.json

# List visuals on a page
Glob: .Report/definition/pages/[PageGUID]/visuals/*/visual.json

# Read specific visual
Read: .Report/definition/pages/[PageGUID]/visuals/[VisualGUID]/visual.json

Step 2: Analyze Visual Structure

Identify:

  1. Visual type - visualType property (card, barChart, lineChart, etc.)
  2. Data roles - Query projections (Values, Category, Y, Series, etc.)
  3. Formatting - Objects in visualContainerObjects and visual.objects
  4. Special features - Interactions, drill-through, conditional formatting

Step 3: Create Placeholders

Replace specific values with {{PLACEHOLDER}} syntax:

Always Replace:

Value Placeholder
Visual GUID (name) {{VISUAL_NAME}}
Position x {{X}}
Position y {{Y}}
Position z {{Z}}
Width {{WIDTH}}
Height {{HEIGHT}}
Tab order {{TAB_ORDER}}
Title text {{TITLE}}
Filter names (GUIDs) {{FILTER_GUID}}

Data Binding Replacements:

Binding Placeholders
Primary measure {{TABLENAME}}, {{MEASURENAME}}
Multiple measures {{MEASURE1TABLE}}, {{MEASURE1NAME}}, etc.
Category axis {{CATEGORYTABLE}}, {{CATEGORYCOLUMN}}
Series/Legend {{SERIESTABLE}}, {{SERIESCOLUMN}}
Matrix rows {{ROWTABLE}}, {{ROWCOLUMN}}
Matrix columns {{COLUMNTABLE}}, {{COLUMNCOLUMN}}
Map location {{LOCATIONTABLE}}, {{LOCATIONCOLUMN}}
Scatter X/Y {{XMEASURETABLE}}, {{YMEASURETABLE}}, etc.

Formatting Replacements (Optional):

Property Placeholder
Font size {{FONT_SIZE}}
Display units {{DISPLAY_UNITS}}
Colors {{MEASURE1COLOR}}, etc.
Legend position {{LEGEND_POSITION}}

Step 4: Validate Template

Before saving, verify:

  • JSON is well-formed
  • All specific values replaced with placeholders
  • Schema reference preserved ($schema)
  • No hardcoded table/column names remain
  • No hardcoded visual names remain

Step 5: Name and Save Template

Naming Convention:

[visual-type]-[variant].json

Examples:
- card-single-measure.json
- line-chart-with-series.json
- slicer-dropdown.json
- azure-map-bubble.json

Save Location:

visual-templates/[template-name].json

Step 6: Update Documentation

Add entry to visual-templates/README.md:

| `[template-name].json` | [Visual Type] | [Description] |

Document any unique placeholders for this template.

Example: Extract a Bar Chart

Source visual.json:

{
  "$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definition/visualContainer/2.4.0/schema.json",
  "name": "SalesByRegionBar",
  "position": {
    "x": "100",
    "y": "200",
    "z": "2000",
    "height": "300",
    "width": "400",
    "tabOrder": "1"
  },
  "visual": {
    "visualType": "barChart",
    "query": {
      "queryState": {
        "Category": {
          "projections": [
            {
              "field": {
                "Column": {
                  "Expression": { "SourceRef": { "Entity": "dim_region" } },
                  "Property": "region_name"
                }
              },
              "queryRef": "dim_region.region_name",
              "nativeQueryRef": "region_name",
              "active": true
            }
          ]
        },
        "Y": {
          "projections": [
            {
              "field": {
                "Measure": {
                  "Expression": { "SourceRef": { "Entity": "Fact_Sales" } },
                  "Property": "Total Sales"
                }
              },
              "queryRef": "Fact_Sales.Total Sales",
              "nativeQueryRef": "Total Sales"
            }
          ]
        }
      }
    }
  }
}

Extracted template:

{
  "$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definition/visualContainer/2.4.0/schema.json",
  "name": "{{VISUAL_NAME}}",
  "position": {
    "x": "{{X}}",
    "y": "{{Y}}",
    "z": "{{Z}}",
    "height": "{{HEIGHT}}",
    "width": "{{WIDTH}}",
    "tabOrder": "{{TAB_ORDER}}"
  },
  "visual": {
    "visualType": "barChart",
    "query": {
      "queryState": {
        "Category": {
          "projections": [
            {
              "field": {
                "Column": {
                  "Expression": { "SourceRef": { "Entity": "{{CATEGORY_TABLE}}" } },
                  "Property": "{{CATEGORY_COLUMN}}"
                }
              },
              "queryRef": "{{CATEGORY_TABLE}}.{{CATEGORY_COLUMN}}",
              "nativeQueryRef": "{{CATEGORY_COLUMN}}",
              "active": true
            }
          ]
        },
        "Y": {
          "projections": [
            {
              "field": {
                "Measure": {
                  "Expression": { "SourceRef": { "Entity": "{{TABLE_NAME}}" } },
                  "Property": "{{MEASURE_NAME}}"
                }
              },
              "queryRef": "{{TABLE_NAME}}.{{MEASURE_NAME}}",
              "nativeQueryRef": "{{MEASURE_NAME}}"
            }
          ]
        }
      }
    }
  }
}

Handling Complex Visuals

Multiple Measures

For visuals with multiple Y values, use numbered placeholders:

{{MEASURE_1_TABLE}}, {{MEASURE_1_NAME}}
{{MEASURE_2_TABLE}}, {{MEASURE_2_NAME}}
{{MEASURE_3_TABLE}}, {{MEASURE_3_NAME}}

Conditional Formatting

Keep conditional formatting rules but placeholder the references:

"rules": [
  {
    "field": {
      "Measure": {
        "Expression": { "SourceRef": { "Entity": "{{TABLE_NAME}}" } },
        "Property": "{{MEASURE_NAME}}"
      }
    }
  }
]

Default Values

Some formatting values should remain hardcoded (good defaults):

  • Font family: Keep as-is (e.g., "Segoe UI")
  • Default colors: Keep unless user wants custom
  • Axis show/hide: Keep as-is

Quality Checklist

Before finalizing template:

  • $schema property preserved at top
  • name → {{VISUAL_NAME}}
  • All position values → placeholders
  • All table names → placeholders
  • All column/measure names → placeholders
  • Filter GUIDs → {{FILTER_GUID}}
  • Title text → {{TITLE}}
  • JSON validates successfully
  • Template follows naming convention

Contribution to Template Library

When adding new templates:

  1. Test the template by creating a visual with it
  2. Verify it opens correctly in Power BI Desktop
  3. Add to visual-templates/README.md
  4. Document any unique placeholders
  5. Add to the "Available Templates" table

Constraints

  • Never modify the source visual.json
  • Always preserve the schema version
  • Use consistent placeholder naming
  • Test templates before adding to library