-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add Power BI modeling skill #657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| --- | ||
| name: powerbi-modeling | ||
| 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. | ||
| --- | ||
|
AlahmadiQ8 marked this conversation as resolved.
AlahmadiQ8 marked this conversation as resolved.
|
||
|
|
||
| # Power BI Semantic Modeling | ||
|
|
||
| Guide users in building optimized, well-documented Power BI semantic models following Microsoft best practices. | ||
|
|
||
| ## When to Use This Skill | ||
|
|
||
| Use this skill when users ask about: | ||
| - Creating or optimizing Power BI semantic models | ||
| - Designing star schemas (dimension/fact tables) | ||
| - Writing DAX measures or calculated columns | ||
| - Configuring table relationships (cardinality, cross-filter) | ||
| - Implementing row-level security (RLS) | ||
| - Naming conventions for tables, columns, measures | ||
| - Adding descriptions and documentation to models | ||
| - Performance tuning and optimization | ||
| - Calculation groups and field parameters | ||
| - Model validation and best practice checks | ||
|
|
||
| **Trigger phrases:** "create a measure", "add relationship", "star schema", "optimize model", "DAX formula", "RLS", "naming convention", "model documentation", "cardinality", "cross-filter" | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Required Tools | ||
| - **Power BI Modeling MCP Server**: Required for connecting to and modifying semantic models | ||
| - Enables: connection_operations, table_operations, measure_operations, relationship_operations, etc. | ||
| - Must be configured and running to interact with models | ||
|
|
||
| ### Optional Dependencies | ||
| - **Microsoft Learn MCP Server**: Recommended for researching latest best practices | ||
| - Enables: microsoft_docs_search, microsoft_docs_fetch | ||
| - Use for complex scenarios, new features, and official documentation | ||
|
|
||
| ## Workflow | ||
|
|
||
| ### 1. Connect and Analyze First | ||
|
|
||
| Before providing any modeling guidance, always examine the current model state: | ||
|
|
||
| ``` | ||
| 1. List connections: connection_operations(operation: "ListConnections") | ||
| 2. If no connection, check for local instances: connection_operations(operation: "ListLocalInstances") | ||
| 3. Connect to the model (Desktop or Fabric) | ||
| 4. Get model overview: model_operations(operation: "Get") | ||
| 5. List tables: table_operations(operation: "List") | ||
| 6. List relationships: relationship_operations(operation: "List") | ||
| 7. List measures: measure_operations(operation: "List") | ||
| ``` | ||
|
|
||
| ### 2. Evaluate Model Health | ||
|
|
||
| After connecting, assess the model against best practices: | ||
|
|
||
| - **Star Schema**: Are tables properly classified as dimension or fact? | ||
| - **Relationships**: Correct cardinality? Minimal bidirectional filters? | ||
| - **Naming**: Human-readable, consistent naming conventions? | ||
| - **Documentation**: Do tables, columns, measures have descriptions? | ||
| - **Measures**: Explicit measures for key calculations? | ||
| - **Hidden Fields**: Are technical columns hidden from report view? | ||
|
|
||
| ### 3. Provide Targeted Guidance | ||
|
|
||
| Based on analysis, guide improvements using references: | ||
| - Star schema design: See [STAR-SCHEMA.md](references/STAR-SCHEMA.md) | ||
| - Relationship configuration: See [RELATIONSHIPS.md](references/RELATIONSHIPS.md) | ||
| - DAX measures and naming: See [MEASURES-DAX.md](references/MEASURES-DAX.md) | ||
| - Performance optimization: See [PERFORMANCE.md](references/PERFORMANCE.md) | ||
| - Row-level security: See [RLS.md](references/RLS.md) | ||
|
|
||
| ## Quick Reference: Model Quality Checklist | ||
|
|
||
| | Area | Best Practice | | ||
| |------|--------------| | ||
| | Tables | Clear dimension vs fact classification | | ||
| | Naming | Human-readable: `Customer Name` not `CUST_NM` | | ||
| | Descriptions | All tables, columns, measures documented | | ||
| | Measures | Explicit DAX measures for business metrics | | ||
| | Relationships | One-to-many from dimension to fact | | ||
| | Cross-filter | Single direction unless specifically needed | | ||
| | Hidden fields | Hide technical keys, IDs from report view | | ||
| | Date table | Dedicated marked date table | | ||
|
|
||
| ## MCP Tools Reference | ||
|
|
||
| Use these Power BI Modeling MCP operations: | ||
|
|
||
| | Operation Category | Key Operations | | ||
| |-------------------|----------------| | ||
| | `connection_operations` | Connect, ListConnections, ListLocalInstances, ConnectFabric | | ||
| | `model_operations` | Get, GetStats, ExportTMDL | | ||
| | `table_operations` | List, Get, Create, Update, GetSchema | | ||
| | `column_operations` | List, Get, Create, Update (descriptions, hidden, format) | | ||
| | `measure_operations` | List, Get, Create, Update, Move | | ||
| | `relationship_operations` | List, Get, Create, Update, Activate, Deactivate | | ||
| | `dax_query_operations` | Execute, Validate | | ||
| | `calculation_group_operations` | List, Create, Update | | ||
| | `security_role_operations` | List, Create, Update, GetEffectivePermissions | | ||
|
|
||
| ## Common Tasks | ||
|
|
||
| ### Add Measure with Description | ||
| ``` | ||
| measure_operations( | ||
| operation: "Create", | ||
| definitions: [{ | ||
| name: "Total Sales", | ||
| tableName: "Sales", | ||
| expression: "SUM(Sales[Amount])", | ||
| formatString: "$#,##0", | ||
| description: "Sum of all sales amounts" | ||
| }] | ||
| ) | ||
| ``` | ||
|
|
||
| ### Update Column Description | ||
| ``` | ||
| column_operations( | ||
| operation: "Update", | ||
| definitions: [{ | ||
| tableName: "Customer", | ||
| name: "CustomerKey", | ||
| description: "Unique identifier for customer dimension", | ||
| isHidden: true | ||
| }] | ||
| ) | ||
| ``` | ||
|
|
||
| ### Create Relationship | ||
| ``` | ||
| relationship_operations( | ||
| operation: "Create", | ||
| definitions: [{ | ||
| fromTable: "Sales", | ||
| fromColumn: "CustomerKey", | ||
| toTable: "Customer", | ||
| toColumn: "CustomerKey", | ||
| crossFilteringBehavior: "OneDirection" | ||
| }] | ||
| ) | ||
| ``` | ||
|
|
||
| ## When to Use Microsoft Learn MCP | ||
|
|
||
| Research current best practices using `microsoft_docs_search` for: | ||
| - Latest DAX function documentation | ||
| - New Power BI features and capabilities | ||
| - Complex modeling scenarios (SCD Type 2, many-to-many) | ||
| - Performance optimization techniques | ||
| - Security implementation patterns | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| # DAX Measures and Naming Conventions | ||
|
|
||
| ## Naming Conventions | ||
|
|
||
| ### General Rules | ||
| - Use human-readable names (spaces allowed) | ||
| - Be descriptive: `Total Sales Amount` not `TSA` | ||
| - Avoid abbreviations unless universally understood | ||
| - Use consistent capitalization (Title Case recommended) | ||
| - Avoid special characters except spaces | ||
|
|
||
| ### Table Naming | ||
| | Type | Convention | Example | | ||
| |------|------------|---------| | ||
| | Dimension | Singular noun | Customer, Product, Date | | ||
| | Fact | Business process | Sales, Orders, Inventory | | ||
| | Bridge | Combined names | CustomerAccount, ProductCategory | | ||
| | Measure Table | Underscore prefix | _Measures, _KPIs | | ||
|
|
||
| ### Column Naming | ||
| | Type | Convention | Example | | ||
| |------|------------|---------| | ||
| | Keys | Suffix with "Key" or "ID" | CustomerKey, ProductID | | ||
| | Dates | Suffix with "Date" | OrderDate, ShipDate | | ||
| | Amounts | Descriptive with unit hint | SalesAmount, QuantitySold | | ||
| | Flags | Prefix with "Is" or "Has" | IsActive, HasDiscount | | ||
|
|
||
| ### Measure Naming | ||
| | Type | Convention | Example | | ||
| |------|------------|---------| | ||
| | Aggregations | Verb + Noun | Total Sales, Count of Orders | | ||
| | Ratios | X per Y or X Rate | Sales per Customer, Conversion Rate | | ||
| | Time Intelligence | Period + Metric | YTD Sales, PY Total Sales | | ||
| | Comparisons | Metric + vs + Baseline | Sales vs Budget, Growth vs PY | | ||
|
|
||
| ## Explicit vs Implicit Measures | ||
|
|
||
| ### Always Create Explicit Measures For: | ||
| 1. Key business metrics users will query | ||
| 2. Complex calculations with filter manipulation | ||
| 3. Measures used in MDX (Excel PivotTables) | ||
| 4. Controlled aggregation (prevent sum of averages) | ||
|
|
||
| ### Implicit Measures (Column Aggregations) | ||
| - Acceptable for simple exploration | ||
| - Set correct SummarizeBy property: | ||
| - Amounts: Sum | ||
| - Keys/IDs: None (Do Not Summarize) | ||
| - Rates/Prices: None or Average | ||
|
|
||
| ## Measure Patterns | ||
|
|
||
| ### Basic Aggregations | ||
| ```dax | ||
| Total Sales = SUM(Sales[SalesAmount]) | ||
| Order Count = COUNTROWS(Sales) | ||
| Average Order Value = DIVIDE([Total Sales], [Order Count]) | ||
| Distinct Customers = DISTINCTCOUNT(Sales[CustomerKey]) | ||
| ``` | ||
|
|
||
| ### Time Intelligence (Requires Date Table) | ||
| ```dax | ||
| YTD Sales = TOTALYTD([Total Sales], 'Date'[Date]) | ||
| MTD Sales = TOTALMTD([Total Sales], 'Date'[Date]) | ||
| PY Sales = CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date])) | ||
| YoY Growth = DIVIDE([Total Sales] - [PY Sales], [PY Sales]) | ||
| ``` | ||
|
|
||
| ### Percentage Calculations | ||
| ```dax | ||
| Sales % of Total = | ||
| DIVIDE( | ||
| [Total Sales], | ||
| CALCULATE([Total Sales], REMOVEFILTERS(Product)) | ||
| ) | ||
|
|
||
| Margin % = DIVIDE([Gross Profit], [Total Sales]) | ||
| ``` | ||
|
|
||
| ### Running Totals | ||
| ```dax | ||
| Running Total = | ||
| CALCULATE( | ||
| [Total Sales], | ||
| FILTER( | ||
| ALL('Date'), | ||
| 'Date'[Date] <= MAX('Date'[Date]) | ||
| ) | ||
| ) | ||
| ``` | ||
|
|
||
| ## Column References | ||
|
|
||
| ### Best Practice: Always Qualify Column Names | ||
| ```dax | ||
| // GOOD - Fully qualified | ||
| Sales Amount = SUM(Sales[SalesAmount]) | ||
|
|
||
| // BAD - Unqualified (can cause ambiguity) | ||
| Sales Amount = SUM([SalesAmount]) | ||
| ``` | ||
|
|
||
| ### Measure References: Never Qualify | ||
| ```dax | ||
| // GOOD - Unqualified measure | ||
| YTD Sales = TOTALYTD([Total Sales], 'Date'[Date]) | ||
|
|
||
| // BAD - Qualified measure (breaks if home table changes) | ||
| YTD Sales = TOTALYTD(Sales[Total Sales], 'Date'[Date]) | ||
| ``` | ||
|
|
||
| ## Documentation | ||
|
|
||
| ### Measure Descriptions | ||
| Always add descriptions explaining: | ||
| - What the measure calculates | ||
| - Business context/usage | ||
| - Any important assumptions | ||
|
|
||
| ``` | ||
| measure_operations( | ||
| operation: "Update", | ||
| definitions: [{ | ||
| name: "Total Sales", | ||
| tableName: "Sales", | ||
| description: "Sum of all completed sales transactions. Excludes returns and cancelled orders." | ||
| }] | ||
| ) | ||
| ``` | ||
|
|
||
| ### Format Strings | ||
| | Data Type | Format String | Example Output | | ||
| |-----------|---------------|----------------| | ||
| | Currency | $#,##0.00 | $1,234.56 | | ||
| | Percentage | 0.0% | 12.3% | | ||
| | Whole Number | #,##0 | 1,234 | | ||
| | Decimal | #,##0.00 | 1,234.56 | | ||
|
|
||
| ## Display Folders | ||
|
|
||
| Organize measures into logical groups: | ||
| ``` | ||
| measure_operations( | ||
| operation: "Update", | ||
| definitions: [{ | ||
| name: "YTD Sales", | ||
| tableName: "_Measures", | ||
| displayFolder: "Time Intelligence\\Year" | ||
| }] | ||
| ) | ||
| ``` | ||
|
|
||
| Common folder structure: | ||
| ``` | ||
| _Measures | ||
| ├── Sales | ||
| │ ├── Total Sales | ||
| │ └── Average Sale | ||
| ├── Time Intelligence | ||
| │ ├── Year | ||
| │ │ ├── YTD Sales | ||
| │ │ └── PY Sales | ||
| │ └── Month | ||
| │ └── MTD Sales | ||
| └── Ratios | ||
| ├── Margin % | ||
| └── Conversion Rate | ||
| ``` | ||
|
|
||
| ## Variables for Performance | ||
|
|
||
| Use variables to: | ||
| - Avoid recalculating the same expression | ||
| - Improve readability | ||
| - Enable debugging | ||
|
|
||
| ```dax | ||
| Gross Margin % = | ||
| VAR TotalSales = [Total Sales] | ||
| VAR TotalCost = [Total Cost] | ||
| VAR GrossProfit = TotalSales - TotalCost | ||
| RETURN | ||
| DIVIDE(GrossProfit, TotalSales) | ||
| ``` | ||
|
|
||
| ## Validation Checklist | ||
|
|
||
| - [ ] All key business metrics have explicit measures | ||
| - [ ] Measures have clear, descriptive names | ||
| - [ ] Measures have descriptions | ||
| - [ ] Appropriate format strings applied | ||
| - [ ] Display folders organize related measures | ||
| - [ ] Column references are fully qualified | ||
| - [ ] Measure references are not qualified | ||
| - [ ] Variables used for complex calculations |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.