/power-bi-dax
Write, execute, and optimize DAX queries and measures for Power BI semantic models using pbi-cli. Invoke this skill whenever the user mentions DAX, queries data in Power BI, writes calculations, creates measures, asks about EVALUATE, SUMMARIZECOLUMNS, CALCULATE, time
$ npx -y skills add MinaSaad1/pbi-cli --skill power-bi-dax --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/power-bi-dax
Context preview
The summary Claude sees to decide when to auto-load this skill.
Write, execute, and optimize DAX queries and measures for Power BI semantic models using pbi-cli. Invoke this skill whenever the user mentions DAX, queries data in Power BI, writes calculations, creates measures, asks about EVALUATE, SUMMARIZECOLUMNS, CALCULATE, time
SKILL.md
power-bi-dax.SKILL.mdname: Power BI DAX
description: Write, execute, and optimize DAX queries and measures for Power BI semantic models using pbi-cli. Invoke this skill whenever the user mentions DAX, queries data in Power BI, writes calculations, creates measures, asks about EVALUATE, SUMMARIZECOLUMNS, CALCULATE, time intelligence, or wants to analyze/aggregate data from a semantic model. Also invoke when the user asks to run a query, test a formula, or check row counts. This skill contains critical guidance on passing DAX expressions via CLI arguments -- multi-line DAX (VAR/RETURN) requires special handling.
tools: pbi-cli
Power BI DAX Skill
Execute and validate DAX queries against connected Power BI models.
Prerequisites
pipx install pbi-cli-tool
pbi-cli skills install
pbi connect
Executing Queries
# Inline query
pbi dax execute "EVALUATE TOPN(10, Sales)"
# From file
pbi dax execute --file query.dax
# From stdin (piping)
cat query.dax | pbi dax execute -
echo "EVALUATE Sales" | pbi dax execute -
# With options
pbi dax execute "EVALUATE Sales" --max-rows 100
pbi dax execute "EVALUATE Sales" --timeout 300 # Custom timeout (seconds)
# JSON output for scripting
pbi --json dax execute "EVALUATE Sales"
DAX Expression Limitations in CLI
When passing DAX as a `-e` argument, the shell collapses newlines into a single line. Simple expressions like `SUM(Sales[Amount])` work fine, but multi-line DAX using VAR/RETURN breaks because the DAX parser needs line breaks between those keywords.
**Why this matters:** A measure like `VAR x = [Total Sales] VAR y = [Sales PY] RETURN DIVIDE(x - y, y)` will fail with a syntax error because the engine sees it as one continuous line without statement separators.
**Workarounds (pick one):**
# Option 1: Pipe from stdin (recommended for measures)
echo 'VAR TotalSales = SUM(Sales[Amount])
VAR TotalCost = SUM(Sales[Cost])
RETURN TotalSales - TotalCost' | pbi measure create "Profit" -e - -t Sales
# Option 2: Write to a .dax file and use --file (for queries)
echo 'EVALUATE
ROW("Result",
VAR x = SUM(Sales[Amount])
RETURN x
)' > query.dax
pbi dax execute --file query.dax**Single-line alternatives (preferred when possible):**
For simple ratio/growth measures, use inline patterns instead of VAR/RETURN:
# Instead of: VAR x = SUM(...) / VAR y = SUM(...) / RETURN DIVIDE(x, y)
# Use inline DIVIDE -- it handles division-by-zero gracefully (returns BLANK):
pbi measure create "Margin %" \
-e "DIVIDE(SUM(Sales[Amount]) - SUM(Sales[Cost]), SUM(Sales[Amount]))" \
-t Sales --format-string "0.0%"
# Instead of: VAR current = [Total Sales] / VAR prev = [Sales PY] / RETURN DIVIDE(...)
# Reference measures directly in DIVIDE:
pbi measure create "YoY %" \
-e "DIVIDE([Total Sales] - [PY Sales], [PY Sales])" \
-t Sales --format-string "0.0%"
Validating Queries
pbi dax validate "EVALUATE Sales"
pbi dax validate --file query.dax
Cache Management
pbi dax clear-cache # Clear the formula engine cache
Creating Measures with DAX
# Simple aggregation
pbi measure create "Total Sales" -e "SUM(Sales[Amount])" -t Sales
# Time intelligence
pbi measure create "YTD Sales" -e "TOTALYTD(SUM(Sales[Amount]), Calendar[Date])" -t Sales
# Previous year comparison
pbi measure create "PY Sales" -e "CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Calendar[Date]))" -t Sales
# Year-over-year change
pbi measure create "YoY %" -e "DIVIDE([Total Sales] - [PY Sales], [PY Sales])" -t Sales --format-string "0.0%"
Common DAX Patterns
Explore Model Data
# List all tables
pbi dax execute "EVALUATE INFO.TABLES()"
# List columns in a table
pbi dax execute "EVALUATE INFO.COLUMNS()"
# Preview table data
pbi dax execute "EVALUATE TOPN(10, Sales)"
# Count rows
pbi dax execute "EVALUATE ROW(\"Count\", COUNTROWS(Sales))"
Aggregations
# Basic sum
pbi dax execute "EVALUATE ROW(\"Total\", SUM(Sales[Amount]))"
# Group by with aggregation
pbi dax execute "EVALUATE SUMMARIZECOLUMNS(Products[Category], \"Total\", SUM(Sales[Amount]))"
# Multiple aggregations
pbi dax execute "
EVALUATE
SUMMARIZECOLUMNS(
Products[Category],
\"Total Sales\", SUM(Sales[Amount]),
\"Avg Price\", AVERAGE(Sales[UnitPrice]),
\"Count\", COUNTROWS(Sales)
)
"Filtering
# CALCULATE with filter
pbi dax execute "
EVALUATE
ROW(\"Online Sales\", CALCULATE(SUM(Sales[Amount]), Sales[Channel] = \"Online\"))
"
# FILTER with complex condition
pbi dax execute "
EVALUATE
FILTER(
SUMMARIZECOLUMNS(Products[Name], \"Total\", SUM(Sales[Amount])),
[Total] > 1000
)
"Time Intelligence
# Year-to-date
pbi dax execute "
EVALUATE
ROW(\"YTD\", TOTALYTD(SUM(Sales[Amount]), Calendar[Date]))
"
# Rolling 12 months
pbi dax execute "
EVALUATE
ROW(\"R12\", CALCULATE(
SUM(Sales[Amount]),
DATESINPERIOD(Calendar[Date], MAX(Calendar[Date]), -12, MONTH)
))
"Ranking
# Top products by sales
pbi dax execute "
EVALUATE
TOPN(
10,
ADDCOLUMNS(
VALUES(Products[Name]),
\"Total\", CALCULATE(SUM(Sales[Amount]))
),
[Total], DESC
)
"Performance Tips
- Use `--max-rows` to limit result sets during development
- Run `pbi dax clear-cache` before benchmarking
- Prefer `SUMMARIZECOLUMNS` over `SUMMARIZE` for grouping
- Use `CALCULATE` with simple filters instead of nested `FILTER`
- Avoid iterators (`SUMX`, `FILTER`) on large tables when aggregations suffice
Read more
name: Power BI DAX description: Write, execute, and optimize DAX queries and measures for Power BI semantic models using pbi-cli. Invoke this skill whenever the user mentions DAX, queries data in Power BI, writes calculations, creates measures, asks about EVALUATE, SUMMARIZECOLUMNS, CALCULATE, time intelligence, or wants to analyze/aggregate data from a semantic model. Also invoke when the user asks to run a query, test a formula, or check row counts. This skill contains critical guidance on passing DAX expressions via CLI arguments -- multi-line DAX (VAR/RETURN) requires special handling. tools: pbi-cli
Power BI DAX Skill
Execute and validate DAX queries against connected Power BI models.
Prerequisites
pipx install pbi-cli-tool pbi-cli skills install pbi connect
Executing Queries
# Inline query pbi dax execute "EVALUATE TOPN(10, Sales)" # From file pbi dax execute --file query.dax # From stdin (piping) cat query.dax | pbi dax execute - echo "EVALUATE Sales" | pbi dax execute - # With options pbi dax execute "EVALUATE Sales" --max-rows 100 pbi dax execute "EVALUATE Sales" --timeout 300 # Custom timeout (seconds) # JSON output for scripting pbi --json dax execute "EVALUATE Sales"
DAX Expression Limitations in CLI
When passing DAX as a `-e` argument, the shell collapses newlines into a single line. Simple expressions like `SUM(Sales[Amount])` work fine, but multi-line DAX using VAR/RETURN breaks because the DAX parser needs line breaks between those keywords.
**Why this matters:** A measure like `VAR x = [Total Sales] VAR y = [Sales PY] RETURN DIVIDE(x - y, y)` will fail with a syntax error because the engine sees it as one continuous line without statement separators.
**Workarounds (pick one):**
# Option 1: Pipe from stdin (recommended for measures)
echo 'VAR TotalSales = SUM(Sales[Amount])
VAR TotalCost = SUM(Sales[Cost])
RETURN TotalSales - TotalCost' | pbi measure create "Profit" -e - -t Sales
# Option 2: Write to a .dax file and use --file (for queries)
echo 'EVALUATE
ROW("Result",
VAR x = SUM(Sales[Amount])
RETURN x
)' > query.dax
pbi dax execute --file query.dax**Single-line alternatives (preferred when possible):**
For simple ratio/growth measures, use inline patterns instead of VAR/RETURN:
# Instead of: VAR x = SUM(...) / VAR y = SUM(...) / RETURN DIVIDE(x, y) # Use inline DIVIDE -- it handles division-by-zero gracefully (returns BLANK): pbi measure create "Margin %" \ -e "DIVIDE(SUM(Sales[Amount]) - SUM(Sales[Cost]), SUM(Sales[Amount]))" \ -t Sales --format-string "0.0%" # Instead of: VAR current = [Total Sales] / VAR prev = [Sales PY] / RETURN DIVIDE(...) # Reference measures directly in DIVIDE: pbi measure create "YoY %" \ -e "DIVIDE([Total Sales] - [PY Sales], [PY Sales])" \ -t Sales --format-string "0.0%"
Validating Queries
pbi dax validate "EVALUATE Sales" pbi dax validate --file query.dax
Cache Management
pbi dax clear-cache # Clear the formula engine cache
Creating Measures with DAX
# Simple aggregation pbi measure create "Total Sales" -e "SUM(Sales[Amount])" -t Sales # Time intelligence pbi measure create "YTD Sales" -e "TOTALYTD(SUM(Sales[Amount]), Calendar[Date])" -t Sales # Previous year comparison pbi measure create "PY Sales" -e "CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Calendar[Date]))" -t Sales # Year-over-year change pbi measure create "YoY %" -e "DIVIDE([Total Sales] - [PY Sales], [PY Sales])" -t Sales --format-string "0.0%"
Common DAX Patterns
Explore Model Data
# List all tables pbi dax execute "EVALUATE INFO.TABLES()" # List columns in a table pbi dax execute "EVALUATE INFO.COLUMNS()" # Preview table data pbi dax execute "EVALUATE TOPN(10, Sales)" # Count rows pbi dax execute "EVALUATE ROW(\"Count\", COUNTROWS(Sales))"
Aggregations
# Basic sum
pbi dax execute "EVALUATE ROW(\"Total\", SUM(Sales[Amount]))"
# Group by with aggregation
pbi dax execute "EVALUATE SUMMARIZECOLUMNS(Products[Category], \"Total\", SUM(Sales[Amount]))"
# Multiple aggregations
pbi dax execute "
EVALUATE
SUMMARIZECOLUMNS(
Products[Category],
\"Total Sales\", SUM(Sales[Amount]),
\"Avg Price\", AVERAGE(Sales[UnitPrice]),
\"Count\", COUNTROWS(Sales)
)
"Filtering
# CALCULATE with filter
pbi dax execute "
EVALUATE
ROW(\"Online Sales\", CALCULATE(SUM(Sales[Amount]), Sales[Channel] = \"Online\"))
"
# FILTER with complex condition
pbi dax execute "
EVALUATE
FILTER(
SUMMARIZECOLUMNS(Products[Name], \"Total\", SUM(Sales[Amount])),
[Total] > 1000
)
"Time Intelligence
# Year-to-date
pbi dax execute "
EVALUATE
ROW(\"YTD\", TOTALYTD(SUM(Sales[Amount]), Calendar[Date]))
"
# Rolling 12 months
pbi dax execute "
EVALUATE
ROW(\"R12\", CALCULATE(
SUM(Sales[Amount]),
DATESINPERIOD(Calendar[Date], MAX(Calendar[Date]), -12, MONTH)
))
"Ranking
# Top products by sales
pbi dax execute "
EVALUATE
TOPN(
10,
ADDCOLUMNS(
VALUES(Products[Name]),
\"Total\", CALCULATE(SUM(Sales[Amount]))
),
[Total], DESC
)
"Performance Tips
- Use `--max-rows` to limit result sets during development
- Run `pbi dax clear-cache` before benchmarking
- Prefer `SUMMARIZECOLUMNS` over `SUMMARIZE` for grouping
- Use `CALCULATE` with simple filters instead of nested `FILTER`
- Avoid iterators (`SUMX`, `FILTER`) on large tables when aggregations suffice
Power BI CLI - semantic models (.NET TOM) and PBIR reports for token-efficient AI agent usage, built for Claude Code
Repo: MinaSaad1/pbi-cli
Other skills on pbi-cli.
- /power-bi-custom-visuals
Vibe-code Power BI custom visuals end-to-end: scaffold a TypeScript project, iterate on src/visual.ts and capabilities.json, validate with the Power BI Visuals SDK toolchain, package to .pbiviz, and import into a PBIR report. Invoke this skill whenever the user mentions "custom
Open skill - /power-bi-deployment
Import and export TMDL/TMSL formats, manage model lifecycle with transactions, and version-control Power BI semantic models using pbi-cli. Invoke this skill whenever the user mentions "deploy", "export", "import", "TMDL", "TMSL", "version control", "git", "backup", "migrate",
Open skill - /power-bi-diagnostics
Troubleshoot Power BI model performance, trace query execution, manage caches, and verify the pbi-cli environment using pbi-cli. Invoke this skill whenever the user says "pbi not working", "setup issues", "connection failed", "slow query", "performance", "profiling", "tracing",
Open skill - /power-bi-docs
Auto-document Power BI semantic models by extracting metadata, generating documentation, and cataloging all model objects using pbi-cli. Invoke this skill whenever the user says "document this model", "what's in this model", "list everything", "data dictionary", "model
Open skill - /power-bi-filters
Add, remove, and manage page-level and visual-level filters on Power BI PBIR reports using pbi-cli. Invoke this skill whenever the user mentions "filter", "TopN filter", "top 10", "bottom 5", "relative date filter", "last 30 days", "categorical filter", "include values",
Open skill - /power-bi-modeling
Create and manage Power BI semantic model structure using pbi-cli -- tables, columns, measures, relationships, hierarchies, calculation groups, and date/calendar tables. Invoke this skill whenever the user says "create table", "add measure", "add column", "create relationship",
Open skill

