lukasreese/pbip-dependency-analyzer
Power BI PBIP Dependency Analyzer. Analyzes all Power BI Project (.pbip) files, TMDL exports, and semantic model definitions to map dependencies between measures, columns, tables, M/Power Query, relationships, and report visuals. Use this skill EVERY TIME the user asks to: find unused measures or columns, analyze dependencies, clean up a data model, check what would break if something is deleted, perform impact analysis, identify orphaned objects, audit model quality, or asks 'what can I delete'. Also trigger when the user uploads .pbip files, model.bim files, TMDL exports, or report.json files and wants to understand their structure or dependencies. Trigger phrases include: 'analyze dependencies', 'find unused', 'what can I delete', 'clean up model', 'impact analysis', 'dependency check', 'unused measures', 'unused columns', 'orphaned objects', 'model audit', 'PBIP analysis'.
npx skills add https://github.com/lukasreese/powerbi-claude-skills --skill pbip-dependency-analyzer
This skill analyzes Power BI Project (PBIP) files to create a complete dependency map across all semantic models and reports. It identifies unused objects (measures, columns, calculated tables) that can be safely deleted, and warns about objects that would cause breaking changes if removed.
When triggered, follow these steps in order:
Check what the user has provided. Look in project knowledge and uploads for:
Accepted file types:
- .pbip files (Power BI Project metadata)
- model.bim (full semantic model JSON)
- TMDL exports (.tmdl text files)
- report.json / pages/ folders (visual definitions)
- .pq / .m files (Power Query / M expressions)
PBIP folder structure reference:
MyReport.pbip
MyReport/
definition/
report.json <- Visual field references
pages/
page1/
visuals/ <- Individual visual configs
model.bim <- Full semantic model
MyModel.pbip
MyModel/
definition/
model.bim <- Semantic model definition
tables/
TableName/
columns/ <- Column definitions
measures/ <- Measure DAX definitions
partitions/ <- M/Power Query or DAX source
relationships/ <- Relationship definitions
expressions/ <- Shared M expressions
TMDL export structure (alternative to PBIP):
model.tmdl <- Model metadata
tables/
TableName.tmdl <- Table with columns, measures, partitions
relationships.tmdl <- All relationships
expressions.tmdl <- Shared expressions
Create a complete inventory. Parse each file type as follows:
Tables — For each table, record:
imported (M/Power Query source), calculated (DAX), or calculationGroupColumns — For each column, record:
source (from M/Power Query), calculated (DAX expression), or rowNumberMeasures — For each measure, record:
Relationships — For each relationship, record:
Calculated Tables — Record:
Hierarchies — Record:
For each query/partition:
For each page and visual:
CRITICAL: Conditional formatting measures often do NOT appear in the visual's value fields. They are defined in the visual's formatting config under objects → values → backColor / foreColor / fontColor. Always check these separately.
For each object, trace ALL inbound and outbound references:
Scan every DAX expression (measures, calculated columns, calculated tables) for:
Reference patterns to detect:
- [MeasureName] -> measure reference
- TableName[ColumnName] -> column reference
- 'Table Name'[ColumnName] -> column reference (quoted table)
- SELECTEDVALUE(Table[Column]) -> column reference
- CALCULATE(..., Table[Column]) -> column reference
- FILTER(TableName, ...) -> table reference
- ALL(TableName) -> table reference
- VALUES(Table[Column]) -> table + column reference
- RELATEDTABLE(TableName) -> table reference + relationship dependency
- RELATED(Table[Column]) -> column reference + relationship dependency
- USERELATIONSHIP(col1, col2) -> specific relationship activation
- TREATAS(...) -> virtual relationship
Build two lists per object:
Scan M expressions for:
- Source references: = OtherQueryName
- Table.Join / Table.NestedJoin -> which columns used in joins
- Table.SelectColumns -> which columns are kept
- Table.RemoveColumns -> which columns are dropped
- Table.RenameColumns -> column name mappings
- #"Query Name" -> query references (quoted)
Columns used in relationships are ALWAYS considered active, even if they appear in no visual or DAX expression. Mark them as ACTIVE - Relationship.
Map each visual field reference back to the semantic model:
Assign each object exactly one status:
| Status | Code | Definition |
|--------|------|-----------|
| Used in Visual | V | Directly in at least one visual's values, rows, columns, legend, tooltip |
| Used in Filter | F | Used only in filters or slicers |
| Used in CF | CF | Used only for conditional formatting |
| Referenced by DAX | D | Not in any visual, but referenced by another measure/calc that IS used |
| Relationship Column | R | Column required for an active relationship |
| M Dependency | M | Column/table required by M/Power Query (join key, intermediate query) |
| Referenced by Orphan | O-CHAIN | Referenced only by objects that are themselves orphaned |
| Orphaned | O | Not referenced by anything, not in any visual |
| Broken Reference | BROKEN | References an object that does not exist |
| Circular | CIRC | Part of a circular dependency chain |
Classification priority (if multiple apply): V > F > CF > D > R > M > O-CHAIN > O
Present findings in this order:
Quick stats:
Total tables: X (Y imported, Z calculated)
Total columns: X (Y source, Z calculated)
Total measures: X
Total relationships: X
Reports analyzed: X
Pages analyzed: X
Visuals analyzed: X
Sort by impact (highest savings first):
For each object:
| Object | Type | Table | Status | Risk | Why Unused |
|--------|------|-------|--------|------|------------|
| Name | Measure/Column/Table | Parent | O / O-CHAIN | LOW/MED/HIGH | No references found / Only referenced by [other orphan] |
Risk levels:
For every ACTIVE object, show the dependency chain:
| Object | Direct Dependents | Indirect Dependents | Visuals | Pages | Reports |
|--------|-------------------|---------------------|---------|-------|---------|
| Name | [list] | [list] | [list] | [list] | [list] |
When user asks "what if I delete X", trace the full chain and list everything that would break.
Check for these issues:
| Category | Check | Severity |
|----------|-------|----------|
| Measures | No description | LOW |
| Measures | No display folder | LOW |
| Measures | Duplicate logic (similar DAX in multiple measures) | MEDIUM |
| Columns | Unused calculated column (expensive for nothing) | MEDIUM |
| Columns | Column with no references and isHidden=false | LOW |
| Relationships | Many-to-Many | HIGH |
| Relationships | Bidirectional cross-filter | MEDIUM |
| Relationships | Inactive relationship | LOW |
| Tables | Table with no relationships (island) | MEDIUM |
| Tables | Calculated table that could be M/Power Query | MEDIUM |
| M/Power Query | Query that disables folding unnecessarily | MEDIUM |
| M/Power Query | Intermediate query not marked as non-reportable | LOW |
| Model | Circular dependency | HIGH |
| Model | Broken references | CRITICAL |
If multiple semantic models are provided:
Provide a prioritized action list:
PRIORITY 1 - Delete Now (zero risk):
- [objects with status O, risk LOW, no hidden flag]
PRIORITY 2 - Delete Together (low risk):
- [orphan chains where all objects in chain are unused]
PRIORITY 3 - Investigate First (medium risk):
- [hidden objects, objects with unclear references]
PRIORITY 4 - Model Optimization:
- [quality warnings, performance improvements]
PRIORITY 5 - Cannot determine (external risk):
- [objects that might be used by Live Connection reports not in this project]
10. USERELATIONSHIP activates inactive relationships: Those relationships and their columns become active in that measure's context
Always use tables for structured data. Keep analysis concise. Lead with actionable findings (what to delete) before detailed analysis.
When the user asks a specific question like "can I delete measure X", skip the full analysis and just trace that one object's dependencies. Show the chain and give a clear YES/NO answer with reasoning.
Take lukasreese/pbip-dependency-analyzer from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.