DAX query authoring, testing, and optimization for Power BI and Microsoft Fabric semantic models. Use when writing DAX measures, debugging calculations, querying semantic models, or optimizing DAX performance.
How this skill is triggered — by the user, by Claude, or both
Slash command
/data-engineering-skills:daxThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Write, test, and optimize DAX queries for Power BI and Microsoft Fabric semantic models.
Write, test, and optimize DAX queries for Power BI and Microsoft Fabric semantic models.
pip install semantic-link semantic-link-labs
import sempy.fabric as fabric
# Run a DAX query against a semantic model
result = fabric.evaluate_dax(
dataset="<semantic-model-name>",
dax_string="""
EVALUATE
SUMMARIZECOLUMNS(
'Date'[Year],
'Date'[Month],
"Total Sales", [Total Sales],
"Order Count", [Order Count]
)
""",
workspace="<workspace-name>"
)
print(result)
Note: evaluate_dax() does not auto-refresh the semantic model. Refresh first if needed:
fabric.refresh_dataset(dataset="<name>", workspace="<workspace>")
az rest --method POST \
--url "https://api.powerbi.com/v1.0/myorg/groups/<workspace-id>/datasets/<dataset-id>/executeQueries" \
--body '{"queries": [{"query": "EVALUATE ROW(\"Test\", 1)"}]}'
Total Profit =
VAR _Revenue = [Total Revenue]
VAR _Cost = [Total Cost]
RETURN
_Revenue - _Cost
-- Apply a filter context modification
Online Sales =
CALCULATE(
[Total Sales],
'Channel'[Channel] = "Online"
)
-- Remove filters
All Product Sales =
CALCULATE(
[Total Sales],
REMOVEFILTERS('Product')
)
-- GOOD: Aggregator (single scan)
Total Sales = SUM('Sales'[Amount])
-- USE WHEN NEEDED: Iterator (row-by-row, then aggregate)
Weighted Avg Price =
DIVIDE(
SUMX('Sales', 'Sales'[Quantity] * 'Sales'[UnitPrice]),
SUM('Sales'[Quantity])
)
For a comprehensive pattern library, see dax-patterns.md.
-- GOOD: Engine-optimized
EVALUATE
SUMMARIZECOLUMNS(
'Product'[Category],
"Total", [Total Sales]
)
-- AVOID: Less efficient
EVALUATE
ADDCOLUMNS(
SUMMARIZE('Sales', 'Product'[Category]),
"Total", [Total Sales]
)
-- BAD: Evaluates [Total Sales] twice
Margin % = DIVIDE([Total Sales] - [Total Cost], [Total Sales])
-- GOOD: Evaluate once with VAR
Margin % =
VAR _Sales = [Total Sales]
RETURN
DIVIDE(_Sales - [Total Cost], _Sales)
-- GOOD: Column filter
CALCULATE([Total Sales], 'Date'[Year] = 2024)
-- AVOID: Table filter (creates a full table scan)
CALCULATE([Total Sales], FILTER('Date', 'Date'[Year] = 2024))
-- Intersects with existing filter context instead of replacing
Category Sales =
CALCULATE(
[Total Sales],
KEEPFILTERS('Product'[Category] = "Electronics")
)
-- Quick test of a measure
EVALUATE ROW("Result", [My Measure])
-- Test with filter context
EVALUATE
CALCULATETABLE(
ROW("Result", [My Measure]),
'Date'[Year] = 2024
)
Debug Filters =
VAR _Filters = CONCATENATEX(
FILTERS('Product'[Category]),
'Product'[Category],
", "
)
RETURN "Filters: " & _Filters
EVALUATE INFO.TABLES()
EVALUATE INFO.COLUMNS()
EVALUATE INFO.MEASURES()
EVALUATE INFO.RELATIONSHIPS()
npx claudepluginhub francoisbgdw/claude-skillsProvides DAX reference for Power BI measures, columns, tables: evaluation contexts, CALCULATE, time intelligence, iterators, table functions, optimization, patterns.
Executes DAX queries against Microsoft Fabric Power BI semantic models to discover metadata (tables, columns, measures, relationships) and retrieve data. Activates on DAX query, semantic model metadata, or EVALUATE requests.
Executes raw DAX queries and inspects metadata (tables, columns, measures, relationships) of Microsoft Fabric Power BI semantic models. Use when you already know the DAX to write or need to explore model structure.