Skip to content

Commit 7ad7c47

Browse files
authored
Merge pull request #657 from AlahmadiQ8/power-bi-modeling-skill
Add Power BI modeling skill
2 parents c9d70db + 3cc2412 commit 7ad7c47

7 files changed

Lines changed: 1040 additions & 0 deletions

File tree

docs/README.skills.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Skills differ from other primitives by supporting bundled assets (scripts, code
4545
| [nuget-manager](../skills/nuget-manager/SKILL.md) | Manage NuGet packages in .NET projects/solutions. Use this skill when adding, removing, or updating NuGet package versions. It enforces using `dotnet` CLI for package management and provides strict procedures for direct file edits only when updating versions. | None |
4646
| [penpot-uiux-design](../skills/penpot-uiux-design/SKILL.md) | Comprehensive guide for creating professional UI/UX designs in Penpot using MCP tools. Use this skill when: (1) Creating new UI/UX designs for web, mobile, or desktop applications, (2) Building design systems with components and tokens, (3) Designing dashboards, forms, navigation, or landing pages, (4) Applying accessibility standards and best practices, (5) Following platform guidelines (iOS, Android, Material Design), (6) Reviewing or improving existing Penpot designs for usability. Triggers: "design a UI", "create interface", "build layout", "design dashboard", "create form", "design landing page", "make it accessible", "design system", "component library". | `references/accessibility.md`<br />`references/component-patterns.md`<br />`references/platform-guidelines.md`<br />`references/setup-troubleshooting.md` |
4747
| [plantuml-ascii](../skills/plantuml-ascii/SKILL.md) | Generate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or mentions plantuml ascii, text diagram, ascii art diagram. Supports: Converting PlantUML diagrams to ASCII art, Creating sequence diagrams, class diagrams, flowcharts in ASCII format, Generating Unicode-enhanced ASCII art with -utxt flag | None |
48+
| [powerbi-modeling](../skills/powerbi-modeling/SKILL.md) | Power BI semantic modeling assistant for building optimized data models. Use when working with Power BI semantic models, creating measures, designing star schemas, configuring relationships, implementing RLS, or optimizing model performance. Triggers on queries about DAX calculations, table relationships, dimension/fact table design, naming conventions, model documentation, cardinality, cross-filter direction, calculation groups, and data model best practices. Always connects to the active model first using power-bi-modeling MCP tools to understand the data structure before providing guidance. | `references/MEASURES-DAX.md`<br />`references/PERFORMANCE.md`<br />`references/RELATIONSHIPS.md`<br />`references/RLS.md`<br />`references/STAR-SCHEMA.md` |
4849
| [prd](../skills/prd/SKILL.md) | Generate high-quality Product Requirements Documents (PRDs) for software systems and AI-powered features. Includes executive summaries, user stories, technical specifications, and risk analysis. | None |
4950
| [refactor](../skills/refactor/SKILL.md) | Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements. | None |
5051
| [scoutqa-test](../skills/scoutqa-test/SKILL.md) | This skill should be used when the user asks to "test this website", "run exploratory testing", "check for accessibility issues", "verify the login flow works", "find bugs on this page", or requests automated QA testing. Triggers on web application testing scenarios including smoke tests, accessibility audits, e-commerce flows, and user flow validation using ScoutQA CLI. IMPORTANT: Use this skill proactively after implementing web application features to verify they work correctly - don't wait for the user to ask for testing. | None |

skills/powerbi-modeling/SKILL.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
---
2+
name: powerbi-modeling
3+
description: 'Power BI semantic modeling assistant for building optimized data models. Use when working with Power BI semantic models, creating measures, designing star schemas, configuring relationships, implementing RLS, or optimizing model performance. Triggers on queries about DAX calculations, table relationships, dimension/fact table design, naming conventions, model documentation, cardinality, cross-filter direction, calculation groups, and data model best practices. Always connects to the active model first using power-bi-modeling MCP tools to understand the data structure before providing guidance.'
4+
---
5+
6+
# Power BI Semantic Modeling
7+
8+
Guide users in building optimized, well-documented Power BI semantic models following Microsoft best practices.
9+
10+
## When to Use This Skill
11+
12+
Use this skill when users ask about:
13+
- Creating or optimizing Power BI semantic models
14+
- Designing star schemas (dimension/fact tables)
15+
- Writing DAX measures or calculated columns
16+
- Configuring table relationships (cardinality, cross-filter)
17+
- Implementing row-level security (RLS)
18+
- Naming conventions for tables, columns, measures
19+
- Adding descriptions and documentation to models
20+
- Performance tuning and optimization
21+
- Calculation groups and field parameters
22+
- Model validation and best practice checks
23+
24+
**Trigger phrases:** "create a measure", "add relationship", "star schema", "optimize model", "DAX formula", "RLS", "naming convention", "model documentation", "cardinality", "cross-filter"
25+
26+
## Prerequisites
27+
28+
### Required Tools
29+
- **Power BI Modeling MCP Server**: Required for connecting to and modifying semantic models
30+
- Enables: connection_operations, table_operations, measure_operations, relationship_operations, etc.
31+
- Must be configured and running to interact with models
32+
33+
### Optional Dependencies
34+
- **Microsoft Learn MCP Server**: Recommended for researching latest best practices
35+
- Enables: microsoft_docs_search, microsoft_docs_fetch
36+
- Use for complex scenarios, new features, and official documentation
37+
38+
## Workflow
39+
40+
### 1. Connect and Analyze First
41+
42+
Before providing any modeling guidance, always examine the current model state:
43+
44+
```
45+
1. List connections: connection_operations(operation: "ListConnections")
46+
2. If no connection, check for local instances: connection_operations(operation: "ListLocalInstances")
47+
3. Connect to the model (Desktop or Fabric)
48+
4. Get model overview: model_operations(operation: "Get")
49+
5. List tables: table_operations(operation: "List")
50+
6. List relationships: relationship_operations(operation: "List")
51+
7. List measures: measure_operations(operation: "List")
52+
```
53+
54+
### 2. Evaluate Model Health
55+
56+
After connecting, assess the model against best practices:
57+
58+
- **Star Schema**: Are tables properly classified as dimension or fact?
59+
- **Relationships**: Correct cardinality? Minimal bidirectional filters?
60+
- **Naming**: Human-readable, consistent naming conventions?
61+
- **Documentation**: Do tables, columns, measures have descriptions?
62+
- **Measures**: Explicit measures for key calculations?
63+
- **Hidden Fields**: Are technical columns hidden from report view?
64+
65+
### 3. Provide Targeted Guidance
66+
67+
Based on analysis, guide improvements using references:
68+
- Star schema design: See [STAR-SCHEMA.md](references/STAR-SCHEMA.md)
69+
- Relationship configuration: See [RELATIONSHIPS.md](references/RELATIONSHIPS.md)
70+
- DAX measures and naming: See [MEASURES-DAX.md](references/MEASURES-DAX.md)
71+
- Performance optimization: See [PERFORMANCE.md](references/PERFORMANCE.md)
72+
- Row-level security: See [RLS.md](references/RLS.md)
73+
74+
## Quick Reference: Model Quality Checklist
75+
76+
| Area | Best Practice |
77+
|------|--------------|
78+
| Tables | Clear dimension vs fact classification |
79+
| Naming | Human-readable: `Customer Name` not `CUST_NM` |
80+
| Descriptions | All tables, columns, measures documented |
81+
| Measures | Explicit DAX measures for business metrics |
82+
| Relationships | One-to-many from dimension to fact |
83+
| Cross-filter | Single direction unless specifically needed |
84+
| Hidden fields | Hide technical keys, IDs from report view |
85+
| Date table | Dedicated marked date table |
86+
87+
## MCP Tools Reference
88+
89+
Use these Power BI Modeling MCP operations:
90+
91+
| Operation Category | Key Operations |
92+
|-------------------|----------------|
93+
| `connection_operations` | Connect, ListConnections, ListLocalInstances, ConnectFabric |
94+
| `model_operations` | Get, GetStats, ExportTMDL |
95+
| `table_operations` | List, Get, Create, Update, GetSchema |
96+
| `column_operations` | List, Get, Create, Update (descriptions, hidden, format) |
97+
| `measure_operations` | List, Get, Create, Update, Move |
98+
| `relationship_operations` | List, Get, Create, Update, Activate, Deactivate |
99+
| `dax_query_operations` | Execute, Validate |
100+
| `calculation_group_operations` | List, Create, Update |
101+
| `security_role_operations` | List, Create, Update, GetEffectivePermissions |
102+
103+
## Common Tasks
104+
105+
### Add Measure with Description
106+
```
107+
measure_operations(
108+
operation: "Create",
109+
definitions: [{
110+
name: "Total Sales",
111+
tableName: "Sales",
112+
expression: "SUM(Sales[Amount])",
113+
formatString: "$#,##0",
114+
description: "Sum of all sales amounts"
115+
}]
116+
)
117+
```
118+
119+
### Update Column Description
120+
```
121+
column_operations(
122+
operation: "Update",
123+
definitions: [{
124+
tableName: "Customer",
125+
name: "CustomerKey",
126+
description: "Unique identifier for customer dimension",
127+
isHidden: true
128+
}]
129+
)
130+
```
131+
132+
### Create Relationship
133+
```
134+
relationship_operations(
135+
operation: "Create",
136+
definitions: [{
137+
fromTable: "Sales",
138+
fromColumn: "CustomerKey",
139+
toTable: "Customer",
140+
toColumn: "CustomerKey",
141+
crossFilteringBehavior: "OneDirection"
142+
}]
143+
)
144+
```
145+
146+
## When to Use Microsoft Learn MCP
147+
148+
Research current best practices using `microsoft_docs_search` for:
149+
- Latest DAX function documentation
150+
- New Power BI features and capabilities
151+
- Complex modeling scenarios (SCD Type 2, many-to-many)
152+
- Performance optimization techniques
153+
- Security implementation patterns
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# DAX Measures and Naming Conventions
2+
3+
## Naming Conventions
4+
5+
### General Rules
6+
- Use human-readable names (spaces allowed)
7+
- Be descriptive: `Total Sales Amount` not `TSA`
8+
- Avoid abbreviations unless universally understood
9+
- Use consistent capitalization (Title Case recommended)
10+
- Avoid special characters except spaces
11+
12+
### Table Naming
13+
| Type | Convention | Example |
14+
|------|------------|---------|
15+
| Dimension | Singular noun | Customer, Product, Date |
16+
| Fact | Business process | Sales, Orders, Inventory |
17+
| Bridge | Combined names | CustomerAccount, ProductCategory |
18+
| Measure Table | Underscore prefix | _Measures, _KPIs |
19+
20+
### Column Naming
21+
| Type | Convention | Example |
22+
|------|------------|---------|
23+
| Keys | Suffix with "Key" or "ID" | CustomerKey, ProductID |
24+
| Dates | Suffix with "Date" | OrderDate, ShipDate |
25+
| Amounts | Descriptive with unit hint | SalesAmount, QuantitySold |
26+
| Flags | Prefix with "Is" or "Has" | IsActive, HasDiscount |
27+
28+
### Measure Naming
29+
| Type | Convention | Example |
30+
|------|------------|---------|
31+
| Aggregations | Verb + Noun | Total Sales, Count of Orders |
32+
| Ratios | X per Y or X Rate | Sales per Customer, Conversion Rate |
33+
| Time Intelligence | Period + Metric | YTD Sales, PY Total Sales |
34+
| Comparisons | Metric + vs + Baseline | Sales vs Budget, Growth vs PY |
35+
36+
## Explicit vs Implicit Measures
37+
38+
### Always Create Explicit Measures For:
39+
1. Key business metrics users will query
40+
2. Complex calculations with filter manipulation
41+
3. Measures used in MDX (Excel PivotTables)
42+
4. Controlled aggregation (prevent sum of averages)
43+
44+
### Implicit Measures (Column Aggregations)
45+
- Acceptable for simple exploration
46+
- Set correct SummarizeBy property:
47+
- Amounts: Sum
48+
- Keys/IDs: None (Do Not Summarize)
49+
- Rates/Prices: None or Average
50+
51+
## Measure Patterns
52+
53+
### Basic Aggregations
54+
```dax
55+
Total Sales = SUM(Sales[SalesAmount])
56+
Order Count = COUNTROWS(Sales)
57+
Average Order Value = DIVIDE([Total Sales], [Order Count])
58+
Distinct Customers = DISTINCTCOUNT(Sales[CustomerKey])
59+
```
60+
61+
### Time Intelligence (Requires Date Table)
62+
```dax
63+
YTD Sales = TOTALYTD([Total Sales], 'Date'[Date])
64+
MTD Sales = TOTALMTD([Total Sales], 'Date'[Date])
65+
PY Sales = CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))
66+
YoY Growth = DIVIDE([Total Sales] - [PY Sales], [PY Sales])
67+
```
68+
69+
### Percentage Calculations
70+
```dax
71+
Sales % of Total =
72+
DIVIDE(
73+
[Total Sales],
74+
CALCULATE([Total Sales], REMOVEFILTERS(Product))
75+
)
76+
77+
Margin % = DIVIDE([Gross Profit], [Total Sales])
78+
```
79+
80+
### Running Totals
81+
```dax
82+
Running Total =
83+
CALCULATE(
84+
[Total Sales],
85+
FILTER(
86+
ALL('Date'),
87+
'Date'[Date] <= MAX('Date'[Date])
88+
)
89+
)
90+
```
91+
92+
## Column References
93+
94+
### Best Practice: Always Qualify Column Names
95+
```dax
96+
// GOOD - Fully qualified
97+
Sales Amount = SUM(Sales[SalesAmount])
98+
99+
// BAD - Unqualified (can cause ambiguity)
100+
Sales Amount = SUM([SalesAmount])
101+
```
102+
103+
### Measure References: Never Qualify
104+
```dax
105+
// GOOD - Unqualified measure
106+
YTD Sales = TOTALYTD([Total Sales], 'Date'[Date])
107+
108+
// BAD - Qualified measure (breaks if home table changes)
109+
YTD Sales = TOTALYTD(Sales[Total Sales], 'Date'[Date])
110+
```
111+
112+
## Documentation
113+
114+
### Measure Descriptions
115+
Always add descriptions explaining:
116+
- What the measure calculates
117+
- Business context/usage
118+
- Any important assumptions
119+
120+
```
121+
measure_operations(
122+
operation: "Update",
123+
definitions: [{
124+
name: "Total Sales",
125+
tableName: "Sales",
126+
description: "Sum of all completed sales transactions. Excludes returns and cancelled orders."
127+
}]
128+
)
129+
```
130+
131+
### Format Strings
132+
| Data Type | Format String | Example Output |
133+
|-----------|---------------|----------------|
134+
| Currency | $#,##0.00 | $1,234.56 |
135+
| Percentage | 0.0% | 12.3% |
136+
| Whole Number | #,##0 | 1,234 |
137+
| Decimal | #,##0.00 | 1,234.56 |
138+
139+
## Display Folders
140+
141+
Organize measures into logical groups:
142+
```
143+
measure_operations(
144+
operation: "Update",
145+
definitions: [{
146+
name: "YTD Sales",
147+
tableName: "_Measures",
148+
displayFolder: "Time Intelligence\\Year"
149+
}]
150+
)
151+
```
152+
153+
Common folder structure:
154+
```
155+
_Measures
156+
├── Sales
157+
│ ├── Total Sales
158+
│ └── Average Sale
159+
├── Time Intelligence
160+
│ ├── Year
161+
│ │ ├── YTD Sales
162+
│ │ └── PY Sales
163+
│ └── Month
164+
│ └── MTD Sales
165+
└── Ratios
166+
├── Margin %
167+
└── Conversion Rate
168+
```
169+
170+
## Variables for Performance
171+
172+
Use variables to:
173+
- Avoid recalculating the same expression
174+
- Improve readability
175+
- Enable debugging
176+
177+
```dax
178+
Gross Margin % =
179+
VAR TotalSales = [Total Sales]
180+
VAR TotalCost = [Total Cost]
181+
VAR GrossProfit = TotalSales - TotalCost
182+
RETURN
183+
DIVIDE(GrossProfit, TotalSales)
184+
```
185+
186+
## Validation Checklist
187+
188+
- [ ] All key business metrics have explicit measures
189+
- [ ] Measures have clear, descriptive names
190+
- [ ] Measures have descriptions
191+
- [ ] Appropriate format strings applied
192+
- [ ] Display folders organize related measures
193+
- [ ] Column references are fully qualified
194+
- [ ] Measure references are not qualified
195+
- [ ] Variables used for complex calculations

0 commit comments

Comments
 (0)