powerbi-pbir
Power BI Report (PBIR) Skill
This skill provides guidance on how to develop Power BI reports using the PBIR (Power BI Report) JSON file format.
Critical
- Schema‑aware: validate JSON against the declared
$schema; call out violations and propose fixes. - Understand the PBIP file structure.
Relationship to Other Skills
- powerbi-semantic-model: Use for semantic model development (tables, measures, DAX). This skill (
powerbi-pbir) handles report layout, visuals, and pages only. - powerbi-tmdl: Use for TMDL syntax when working with semantic model definition files.
- fabric-cli: Use for workspace operations, deploying, and exporting report definitions.
Pre-development: Understand the Report
Before making any changes to an existing report, always gather context first:
- Verify PBIR format — Confirm the report has a
definition/folder withreport.json,pages/, andversion.json. - List all pages — Read
pages/pages.jsonto understand the page structure and order. - List visuals per page — For each page, list the visual folders and read each
visual.jsonto understand visual types, positions, and field mappings. - Identify the semantic model — Read
definition.pbirto understand which semantic model the report is connected to (byPathorbyConnection). - Check theme and resources — Review
StaticResources/RegisteredResources/for custom themes and images.
PBIR file format
Example of a report folder using PBIR format:
Report/
├── StaticResources/ # stores report resources such as images, custom themes,...
│ ├── RegisteredResources/
│ │ ├── logo.jpg
│ │ ├── CustomTheme4437032645752863.json
├── definition/ # stores the entire report definition: pages, visuals, bookmarks
│ ├── bookmarks/
│ │ ├── Bookmark7c19b7211ada7de10c30.bookmark.json
│ │ ├── bookmarks.json
│ ├── pages/
│ │ ├── 61481e08c8c340011ce0/
│ │ │ ├── visuals/
│ │ │ │ ├── 3852e5607b224b8ebd1a/
│ │ │ │ │ ├── visual.json
│ │ │ │ │ ├── mobile.json
│ │ │ │ ├── 7df3763f63115a096029/
│ │ │ │ │ ├── visual.json
│ │ │ ├── page.json
│ │ ├── pages.json
│ ├── version.json
│ ├── report.json
├── semanticModelDiagramLayout.json # Copy of the semantic model diagram layout the report is connected to.
└── definition.pbir # Overall definition of the report and core settings. Also holds the reference to the semantic model of the report, it's possible to rebind the report to a different semantic model by updating this file.
Name property
All report objects have a name property. For example see the visual.json:
{
"$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definition/visualContainer/2.1.0/schema.json",
"name": "5868707ac858bcbe007a",
"position": {
"x": 32.118081180811807,
"y": 216.32472324723247,
"z": 4000,
"height": 492.16236162361622,
"width": 366.52398523985238,
"tabOrder": 2000
},
"visual": {
"visualType": "barChart",
"drillFilterOtherVisuals": true
}
}
By default PBIR folder uses the internal name property of pages, visuals and bookmarks in the files or folders. For example consider the following path of a visual:
Sales.Report\definition\pages\89a9619c7025093ade1c\visuals\5acb1caf298449a8acb4\visual.json
89a9619c7025093ade1c is the name of the page and 5acb1caf298449a8acb4 the name of the visual.
Task: Create new report on top of semantic model
- Understand the semantic model — Before creating any report, ensure you have a good understanding of the semantic model: its tables, key measures, dimensions, and date/calendar table.
- Create or reuse PBIP folder — Create a new PBIP report folder structure or reuse an existing one. Follow the PBIP structure.
- Copy template files — Copy
assets/templateReport/report/definitionandassets/templateReport/report/StaticResourcesto the*.Reportfolder. - Configure the semantic model reference — Update
definition.pbirto point to the target semantic model (usebyPathfor local,byConnectionfor workspace). - Adapt visuals to the semantic model — Load template-report-kb.md and follow its instructions to map each visual to the semantic model fields (title, topCard, dateSlicer, barChart, timeSeries).
- Validate — Run the Post-development validation steps.
Task: Edit an existing report
Use this workflow when the user wants to add/modify/remove visuals, pages, or bookmarks in an existing report.
- Locate the report — Determine source (PBIP folder or export from workspace) and access the PBIR files.
- Run Pre-development discovery — Follow the Pre-development steps to understand the current report structure.
- Plan changes — Based on the user request, identify which files need to be created, edited, or removed.
- Execute changes — Apply modifications:
- If adding visuals: create a new folder under the page's
visuals/directory with avisual.jsonfile. Use the correct$schemaand set appropriateposition,visual.visualType, and field mappings. - If editing visuals: modify the
visual.json— update field mappings, position, or visual type. - If adding pages: create a new page folder under
pages/, add apage.json, and updatepages/pages.jsonwith the new page entry. - If removing objects: delete the folder/file and update parent index files (e.g.,
pages.json,bookmarks.json).
- If adding visuals: create a new folder under the page's
- Validate — Run the Post-development validation steps.
Task: Align Power BI Report visuals
- Verify PBIR format — Confirm there is a
definition/folder with the report pages. - For each page, perform the following:
- Inspect all visual.json files — Read the
positionproperty of each visual (x,y,height,width,z,tabOrder) and take into consideration the page dimensions (default 1280x720) inpage.jsonto understand the current layout and identify misalignments or overlaps. - Build a wireframe — Map out each visual's X/Y position and dimensions to understand the current layout.
- Infer the layout grid — Identify rows and columns in the current arrangement. Group visuals into rows and columns based on similar
y(for rows) andx(for columns) values. - Apply consistent alignment:
- Ensure horizontal and vertical distribution is even across rows and columns.
- If a row has only one visual, expand its width to fill the row.
- When possible, make all visuals in the same row have the same height and width.
- Update position values — Edit each
visual.jsonwith the correctedpositionproperties.
- Inspect all visual.json files — Read the
Task: Rename folders to improve readability
- Identify target objects — The internal
nameproperty is used by default in folder and file names. You can rename folders for: pages, visuals, and bookmarks. - Rename the folder — Change the folder name to a human-readable name (e.g.,
mainPage,salesBarChart,dateFilter). - Verify references — Ensure no other files reference the old folder name (internal
nameproperty in JSON files remains unchanged — only the folder name changes).
Task: Export a report from Workspace
- Create folder structure — Set up the PBIP folder structure following the PBIP guidelines.
- Export using Fabric CLI — Use the
fabric-cliskill to export the report code definition from the workspace. - Place files correctly — Ensure the exported definition goes into the
[Name].Report/definition/local folder. - Verify — Confirm the exported folder contains
report.json,version.json, andpages/with at least one page.
Task: Import/Deploy a report to a Workspace
-
Update
definition.pbir— CRITICAL: When deploying a report to a workspace, thedefinition.pbirmust use abyConnectionconfiguration targeting a workspace semantic model:{ "$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definitionProperties/2.0.0/schema.json", "version": "4.0", "datasetReference": { "byConnection": { "connectionString": "semanticmodelid=[SemanticModelId]" } } } -
Deploy using Fabric CLI — Use the
fabric-cliskill to deploy. You can deploy with a new name if needed. -
Verify deployment — Confirm the report appears in the target workspace and opens correctly.
Task: Rebind Power BI Report to a different semantic model
Target is a local PBIP folder
-
Edit
definition.pbir— Configure abyPathproperty using a relative reference to the semantic model folder:{ "$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definitionProperties/2.0.0/schema.json", "version": "4.0", "datasetReference": { "byPath": { "path": "../Sales.SemanticModel" } } } -
Verify field references — After rebinding, check that visual field mappings (
EntityandPropertyreferences invisual.jsonfiles) are still valid against the new semantic model.
Target is in a Fabric workspace
-
Find the semantic model ID — Use Fabric CLI or workspace API to locate the target semantic model ID.
-
Edit
definition.pbir— Configure abyConnectionproperty targeting the semantic model ID:{ "$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definitionProperties/2.0.0/schema.json", "version": "4.0", "datasetReference": { "byConnection": { "connectionString": "semanticmodelid=[SemanticModelId]" } } } -
Verify field references — Ensure visual field mappings are compatible with the new semantic model.
Post-development: Validate Changes
After any report modification, always verify your work:
- Validate file structure - Ensure all required files and folders are present and correctly named. (See PBIR file format).
- Validate JSON schemas — Ensure all edited JSON files are valid against their declared
$schemaURL. - Check visual field mappings — Verify that
Entity(table name) andProperty(column/measure name) references invisual.jsonfiles match the connected semantic model. - Verify page index — Confirm
pages/pages.jsonlists all page folders and the order is correct. - Check visual positions — Ensure no overlapping visuals and that positions make sense within the page dimensions.
- Validate
definition.pbir— Confirm the semantic model reference (byPathorbyConnection) is correctly configured.
Task: Analyze report against best practices
Run the script scripts/bpa.ps1 against the report definition. If no specific BPA rules are mentioned, use the default set of rules in scripts/bpa-rules-report.json.
-
Run BPA — Execute the Best Practice Analysis script:
scripts/bpa.ps1 -reports [path to the report definition folder] -rulesFilePath [path to the BPA rules json file] -
Report findings — Categorize results by severity levels (Critical, High, Medium, Info) and propose fixes.
Error Handling
- Invalid JSON schema: Read the
$schemaURL, validate the file structure against it, and fix any missing or extra properties. - Broken field references: If a visual references a table or column that doesn't exist in the semantic model, update the
EntityandPropertyvalues to match valid semantic model objects. - Deployment failure: Verify that
definition.pbirusesbyConnection(notbyPath) when deploying to a workspace. Check that the semantic model ID is correct. - Missing pages or visuals after export: Verify the export completed fully. Re-export if the
pages/folder is missing subfolders. - Template adaptation issues: If the template report visuals don't render correctly, verify that field mappings use exact table and measure names from the semantic model (case-sensitive).
References
External references (request markdown when possible):