
Power Query
Author, validate, and test Power Query M expressions in semantic model partitions.
Install
npx skills add data-goblin/power-bi-agentic-development --skill power-query -g -a claude-code -y- Repository
- data-goblin/power-bi-agentic-development1.1k
- Category
- Testing
- Updated
- 5d ago
- License
- GPL-3.0
- Context cost
- Mediumabout 2,136 tokens
- Runs scripts
- Yes, review before use
What it does
Author, validate, and test Power Query M expressions in semantic model partitions. Automatically invoke when the user mentions "Power Query", "M code", "M expression", "partition expression", "query folding", or asks to "write Power Query", "fix Power Query", "test a partition", "preview partition data", "debug Power Query step", "optimize Power Query".
Power Query for Semantic Models
Author, validate, and test Power Query M expressions in semantic model import partitions. Covers writing correct M code, preserving query folding, validating expressions, and testing them by executing against real data sources.
Partition Expressions
Each import table in a semantic model has a partition with an M expression defining what data gets loaded during refresh. The expression typically connects to a data source, navigates to a table/view, and applies transformations.
Structure of a Partition Expression
let
Source = Sql.Database(#"SqlEndpoint", #"Database"),
Data = Source{[Schema="dbo", Item="Orders"]}[Data],
#"Removed Columns" = Table.RemoveColumns(Data, {"InternalId"}),
#"Changed Type" = Table.TransformColumnTypes(#"Removed Columns", {{"Amount", Currency.Type}})
in
#"Changed Type"
Key elements:
- Parameters:
#"SqlEndpoint",#"Database"are shared M parameters defined at the model level - Navigation:
Source{[Schema="dbo", Item="Orders"]}[Data]navigates to a specific table - Steps: Each step is a named variable in the
let...inchain - Quoted identifiers: Step names with spaces use
#"Step Name"syntax
Extracting Expressions
# Get partition expression from TMDL via fab
fab get "<Workspace>.Workspace/<Model>.SemanticModel" -f \
-q "definition.parts[?path=='definition/tables/<Table>.tmdl'].payload"
# Get shared M parameters
fab get "<Workspace>.Workspace/<Model>.SemanticModel" -f \
-q "definition.parts[?path=='definition/expressions.tmdl'].payload"
Writing M Expressions
Query Folding
Query folding is the most important performance concept. The M engine translates compatible steps into native data source queries (e.g., SQL). When folding breaks, subsequent steps run in the mashup engine, pulling all data into memory first.


